diff options
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/CMakeLists.txt | 7 | ||||
| -rw-r--r-- | src/common/bit_field.h | 15 | ||||
| -rw-r--r-- | src/common/bounded_threadsafe_queue.h | 9 |
3 files changed, 15 insertions, 16 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 46cf75fde..c0555f840 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt | |||
| @@ -156,12 +156,13 @@ if (MSVC) | |||
| 156 | ) | 156 | ) |
| 157 | target_compile_options(common PRIVATE | 157 | target_compile_options(common PRIVATE |
| 158 | /W4 | 158 | /W4 |
| 159 | /WX | 159 | |
| 160 | /we4242 # 'identifier': conversion from 'type1' to 'type2', possible loss of data | ||
| 161 | /we4254 # 'operator': conversion from 'type1:field_bits' to 'type2:field_bits', possible loss of data | ||
| 162 | /we4800 # Implicit conversion from 'type' to bool. Possible information loss | ||
| 160 | ) | 163 | ) |
| 161 | else() | 164 | else() |
| 162 | target_compile_options(common PRIVATE | 165 | target_compile_options(common PRIVATE |
| 163 | -Werror | ||
| 164 | |||
| 165 | $<$<CXX_COMPILER_ID:Clang>:-fsized-deallocation> | 166 | $<$<CXX_COMPILER_ID:Clang>:-fsized-deallocation> |
| 166 | ) | 167 | ) |
| 167 | endif() | 168 | endif() |
diff --git a/src/common/bit_field.h b/src/common/bit_field.h index 7e1df62b1..e4e58ea45 100644 --- a/src/common/bit_field.h +++ b/src/common/bit_field.h | |||
| @@ -141,10 +141,6 @@ public: | |||
| 141 | constexpr BitField(BitField&&) noexcept = default; | 141 | constexpr BitField(BitField&&) noexcept = default; |
| 142 | constexpr BitField& operator=(BitField&&) noexcept = default; | 142 | constexpr BitField& operator=(BitField&&) noexcept = default; |
| 143 | 143 | ||
| 144 | [[nodiscard]] constexpr operator T() const { | ||
| 145 | return Value(); | ||
| 146 | } | ||
| 147 | |||
| 148 | constexpr void Assign(const T& value) { | 144 | constexpr void Assign(const T& value) { |
| 149 | #ifdef _MSC_VER | 145 | #ifdef _MSC_VER |
| 150 | storage = static_cast<StorageType>((storage & ~mask) | FormatValue(value)); | 146 | storage = static_cast<StorageType>((storage & ~mask) | FormatValue(value)); |
| @@ -162,6 +158,17 @@ public: | |||
| 162 | return ExtractValue(storage); | 158 | return ExtractValue(storage); |
| 163 | } | 159 | } |
| 164 | 160 | ||
| 161 | template <typename ConvertedToType> | ||
| 162 | [[nodiscard]] constexpr ConvertedToType As() const { | ||
| 163 | static_assert(!std::is_same_v<T, ConvertedToType>, | ||
| 164 | "Unnecessary cast. Use Value() instead."); | ||
| 165 | return static_cast<ConvertedToType>(Value()); | ||
| 166 | } | ||
| 167 | |||
| 168 | [[nodiscard]] constexpr operator T() const { | ||
| 169 | return Value(); | ||
| 170 | } | ||
| 171 | |||
| 165 | [[nodiscard]] constexpr explicit operator bool() const { | 172 | [[nodiscard]] constexpr explicit operator bool() const { |
| 166 | return Value() != 0; | 173 | return Value() != 0; |
| 167 | } | 174 | } |
diff --git a/src/common/bounded_threadsafe_queue.h b/src/common/bounded_threadsafe_queue.h index 7e465549b..21217801e 100644 --- a/src/common/bounded_threadsafe_queue.h +++ b/src/common/bounded_threadsafe_queue.h | |||
| @@ -21,11 +21,6 @@ constexpr size_t hardware_interference_size = std::hardware_destructive_interfer | |||
| 21 | constexpr size_t hardware_interference_size = 64; | 21 | constexpr size_t hardware_interference_size = 64; |
| 22 | #endif | 22 | #endif |
| 23 | 23 | ||
| 24 | #ifdef _MSC_VER | ||
| 25 | #pragma warning(push) | ||
| 26 | #pragma warning(disable : 4324) | ||
| 27 | #endif | ||
| 28 | |||
| 29 | template <typename T, size_t capacity = 0x400> | 24 | template <typename T, size_t capacity = 0x400> |
| 30 | class MPSCQueue { | 25 | class MPSCQueue { |
| 31 | public: | 26 | public: |
| @@ -160,8 +155,4 @@ private: | |||
| 160 | static_assert(std::is_nothrow_destructible_v<T>, "T must be nothrow destructible"); | 155 | static_assert(std::is_nothrow_destructible_v<T>, "T must be nothrow destructible"); |
| 161 | }; | 156 | }; |
| 162 | 157 | ||
| 163 | #ifdef _MSC_VER | ||
| 164 | #pragma warning(pop) | ||
| 165 | #endif | ||
| 166 | |||
| 167 | } // namespace Common | 158 | } // namespace Common |