diff options
Diffstat (limited to '')
-rw-r--r-- | src/common/alignment.h | 7 | ||||
-rw-r--r-- | src/common/settings.h | 5 | ||||
-rw-r--r-- | src/common/string_util.cpp | 12 | ||||
-rw-r--r-- | src/common/string_util.h | 2 |
4 files changed, 15 insertions, 11 deletions
diff --git a/src/common/alignment.h b/src/common/alignment.h index 1b56569d1..8570c7d3c 100644 --- a/src/common/alignment.h +++ b/src/common/alignment.h @@ -64,7 +64,7 @@ public: using propagate_on_container_copy_assignment = std::true_type; using propagate_on_container_move_assignment = std::true_type; using propagate_on_container_swap = std::true_type; - using is_always_equal = std::true_type; + using is_always_equal = std::false_type; constexpr AlignmentAllocator() noexcept = default; @@ -83,6 +83,11 @@ public: struct rebind { using other = AlignmentAllocator<T2, Align>; }; + + template <typename T2, size_t Align2> + constexpr bool operator==(const AlignmentAllocator<T2, Align2>&) const noexcept { + return std::is_same_v<T, T2> && Align == Align2; + } }; } // namespace Common diff --git a/src/common/settings.h b/src/common/settings.h index 402339443..9ff4cf85d 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -7,7 +7,6 @@ #include <algorithm> #include <array> #include <atomic> -#include <chrono> #include <map> #include <optional> #include <string> @@ -487,9 +486,9 @@ struct Values { // System Setting<std::optional<u32>> rng_seed{std::optional<u32>(), "rng_seed"}; // Measured in seconds since epoch - std::optional<std::chrono::seconds> custom_rtc; + std::optional<s64> custom_rtc; // Set on game boot, reset on stop. Seconds difference between current time and `custom_rtc` - std::chrono::seconds custom_rtc_differential; + s64 custom_rtc_differential; BasicSetting<s32> current_user{0, "current_user"}; RangedSetting<s32> language_index{1, 0, 17, "language_index"}; diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp index e6344fd41..662171138 100644 --- a/src/common/string_util.cpp +++ b/src/common/string_util.cpp @@ -180,20 +180,20 @@ std::wstring UTF8ToUTF16W(const std::string& input) { #endif -std::string StringFromFixedZeroTerminatedBuffer(const char* buffer, std::size_t max_len) { +std::string StringFromFixedZeroTerminatedBuffer(std::string_view buffer, std::size_t max_len) { std::size_t len = 0; - while (len < max_len && buffer[len] != '\0') + while (len < buffer.length() && len < max_len && buffer[len] != '\0') { ++len; - - return std::string(buffer, len); + } + return std::string(buffer.begin(), buffer.begin() + len); } std::u16string UTF16StringFromFixedZeroTerminatedBuffer(std::u16string_view buffer, std::size_t max_len) { std::size_t len = 0; - while (len < max_len && buffer[len] != '\0') + while (len < buffer.length() && len < max_len && buffer[len] != '\0') { ++len; - + } return std::u16string(buffer.begin(), buffer.begin() + len); } diff --git a/src/common/string_util.h b/src/common/string_util.h index 7e90a9ca5..f0dd632ee 100644 --- a/src/common/string_util.h +++ b/src/common/string_util.h @@ -63,7 +63,7 @@ template <typename InIt> * Creates a std::string from a fixed-size NUL-terminated char buffer. If the buffer isn't * NUL-terminated then the string ends at max_len characters. */ -[[nodiscard]] std::string StringFromFixedZeroTerminatedBuffer(const char* buffer, +[[nodiscard]] std::string StringFromFixedZeroTerminatedBuffer(std::string_view buffer, std::size_t max_len); /** |