diff --git a/Utilities/File.h b/Utilities/File.h index 5c87f8f0d2..02a54bb8f8 100644 --- a/Utilities/File.h +++ b/Utilities/File.h @@ -290,16 +290,16 @@ namespace fs } // Write POD unconditionally - template - std::enable_if_t::value && !std::is_pointer::value, const file&> write(const T& data) const + template + std::enable_if_t && !std::is_pointer_v, const file&> write(const T& data) const { if (write(std::addressof(data), sizeof(T)) != sizeof(T)) xfail(); return *this; } // Write POD std::vector unconditionally - template - std::enable_if_t::value && !std::is_pointer::value, const file&> write(const std::vector& vec) const + template + std::enable_if_t && !std::is_pointer_v, const file&> write(const std::vector& vec) const { if (write(vec.data(), vec.size() * sizeof(T)) != vec.size() * sizeof(T)) xfail(); return *this; @@ -319,30 +319,30 @@ namespace fs } // Read POD, sizeof(T) is used - template - std::enable_if_t::value && !std::is_pointer::value, bool> read(T& data) const + template + std::enable_if_t && !std::is_pointer_v, bool> read(T& data) const { return read(&data, sizeof(T)) == sizeof(T); } // Read POD std::vector, size must be set by resize() method - template - std::enable_if_t::value && !std::is_pointer::value, bool> read(std::vector& vec) const + template + std::enable_if_t && !std::is_pointer_v, bool> read(std::vector& vec) const { return read(vec.data(), sizeof(T) * vec.size()) == sizeof(T) * vec.size(); } // Read POD std::vector - template - std::enable_if_t::value && !std::is_pointer::value, bool> read(std::vector& vec, std::size_t size) const + template + std::enable_if_t && !std::is_pointer_v, bool> read(std::vector& vec, std::size_t size) const { vec.resize(size); return read(vec.data(), sizeof(T) * size) == sizeof(T) * size; } // Read POD (experimental) - template - std::enable_if_t::value && !std::is_pointer::value, T> read() const + template + std::enable_if_t && !std::is_pointer_v, T> read() const { T result; if (!read(result)) xfail(); @@ -360,7 +360,7 @@ namespace fs // Read full file to std::vector template - std::enable_if_t::value && !std::is_pointer::value, std::vector> to_vector() const + std::enable_if_t && !std::is_pointer_v, std::vector> to_vector() const { std::vector result; result.resize(size() / sizeof(T)); diff --git a/Utilities/types.h b/Utilities/types.h index 3eef35eea5..728bfb9313 100644 --- a/Utilities/types.h +++ b/Utilities/types.h @@ -822,19 +822,19 @@ struct alignas(A) any_pod any_pod() = default; - template , typename = std::enable_if_t::value && sizeof(T2) == S && alignof(T2) <= A>> + template , typename = std::enable_if_t && sizeof(T2) == S && alignof(T2) <= A>> any_pod(const T& value) { - reinterpret_cast(data) = value; + *this = std::bit_cast(value); } - template , typename = std::enable_if_t::value && sizeof(T2) == S && alignof(T2) <= A>> + template , typename = std::enable_if_t && sizeof(T2) == S && alignof(T2) <= A>> T2& as() { return reinterpret_cast(data); } - template , typename = std::enable_if_t::value && sizeof(T2) == S && alignof(T2) <= A>> + template , typename = std::enable_if_t && sizeof(T2) == S && alignof(T2) <= A>> const T2& as() const { return reinterpret_cast(data); @@ -899,7 +899,7 @@ struct cmd64 : any64 } }; -static_assert(sizeof(cmd64) == 8 && std::is_pod::value, "Incorrect cmd64 type"); +static_assert(sizeof(cmd64) == 8 && std::is_trivially_copyable_v, "Incorrect cmd64 type"); // Error code type (return type), implements error reporting. Could be a template. struct error_code