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)    )    target_compile_options(common PRIVATE      /W4 -    /WX + +    /we4242 # 'identifier': conversion from 'type1' to 'type2', possible loss of data +    /we4254 # 'operator': conversion from 'type1:field_bits' to 'type2:field_bits', possible loss of data +    /we4800 # Implicit conversion from 'type' to bool. Possible information loss    )  else()    target_compile_options(common PRIVATE -    -Werror -      $<$<CXX_COMPILER_ID:Clang>:-fsized-deallocation>    )  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:      constexpr BitField(BitField&&) noexcept = default;      constexpr BitField& operator=(BitField&&) noexcept = default; -    [[nodiscard]] constexpr operator T() const { -        return Value(); -    } -      constexpr void Assign(const T& value) {  #ifdef _MSC_VER          storage = static_cast<StorageType>((storage & ~mask) | FormatValue(value)); @@ -162,6 +158,17 @@ public:          return ExtractValue(storage);      } +    template <typename ConvertedToType> +    [[nodiscard]] constexpr ConvertedToType As() const { +        static_assert(!std::is_same_v<T, ConvertedToType>, +                      "Unnecessary cast. Use Value() instead."); +        return static_cast<ConvertedToType>(Value()); +    } + +    [[nodiscard]] constexpr operator T() const { +        return Value(); +    } +      [[nodiscard]] constexpr explicit operator bool() const {          return Value() != 0;      } 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  constexpr size_t hardware_interference_size = 64;  #endif -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4324) -#endif -  template <typename T, size_t capacity = 0x400>  class MPSCQueue {  public: @@ -160,8 +155,4 @@ private:      static_assert(std::is_nothrow_destructible_v<T>, "T must be nothrow destructible");  }; -#ifdef _MSC_VER -#pragma warning(pop) -#endif -  } // namespace Common | 
