File indexing completed on 2025-01-18 09:54:05
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef CATCH_COMPARE_TRAITS_HPP_INCLUDED
0009 #define CATCH_COMPARE_TRAITS_HPP_INCLUDED
0010
0011 #include <catch2/internal/catch_void_type.hpp>
0012
0013 #include <type_traits>
0014
0015 namespace Catch {
0016 namespace Detail {
0017
0018 #if defined( __GNUC__ ) && !defined( __clang__ )
0019 # pragma GCC diagnostic push
0020
0021
0022 # pragma GCC diagnostic ignored "-Wbool-compare"
0023
0024
0025 # pragma GCC diagnostic ignored "-Wextra"
0026
0027
0028 # pragma GCC diagnostic ignored "-Wfloat-equal"
0029 #endif
0030
0031 #if defined( __clang__ )
0032 # pragma clang diagnostic push
0033
0034
0035 # pragma clang diagnostic ignored "-Wfloat-equal"
0036 #endif
0037
0038 #define CATCH_DEFINE_COMPARABLE_TRAIT( id, op ) \
0039 template <typename, typename, typename = void> \
0040 struct is_##id##_comparable : std::false_type {}; \
0041 template <typename T, typename U> \
0042 struct is_##id##_comparable< \
0043 T, \
0044 U, \
0045 void_t<decltype( std::declval<T>() op std::declval<U>() )>> \
0046 : std::true_type {}; \
0047 template <typename, typename = void> \
0048 struct is_##id##_0_comparable : std::false_type {}; \
0049 template <typename T> \
0050 struct is_##id##_0_comparable<T, \
0051 void_t<decltype( std::declval<T>() op 0 )>> \
0052 : std::true_type {};
0053
0054
0055 CATCH_DEFINE_COMPARABLE_TRAIT( lt, < )
0056 CATCH_DEFINE_COMPARABLE_TRAIT( le, <= )
0057 CATCH_DEFINE_COMPARABLE_TRAIT( gt, > )
0058 CATCH_DEFINE_COMPARABLE_TRAIT( ge, >= )
0059 CATCH_DEFINE_COMPARABLE_TRAIT( eq, == )
0060 CATCH_DEFINE_COMPARABLE_TRAIT( ne, != )
0061
0062 #undef CATCH_DEFINE_COMPARABLE_TRAIT
0063
0064 #if defined( __GNUC__ ) && !defined( __clang__ )
0065 # pragma GCC diagnostic pop
0066 #endif
0067 #if defined( __clang__ )
0068 # pragma clang diagnostic pop
0069 #endif
0070
0071
0072 }
0073 }
0074
0075 #endif