Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 10:26:39

0001 /// \file
0002 // Range v3 library
0003 //
0004 //  Copyright Eric Niebler 2013-present
0005 //  Copyright Casey Carter 2016
0006 //
0007 //  Use, modification and distribution is subject to the
0008 //  Boost Software License, Version 1.0. (See accompanying
0009 //  file LICENSE_1_0.txt or copy at
0010 //  http://www.boost.org/LICENSE_1_0.txt)
0011 //
0012 // Project home: https://github.com/ericniebler/range-v3
0013 //
0014 #ifndef RANGES_V3_FUNCTIONAL_COMPARISONS_HPP
0015 #define RANGES_V3_FUNCTIONAL_COMPARISONS_HPP
0016 
0017 #include <concepts/concepts.hpp>
0018 
0019 #include <range/v3/range_fwd.hpp>
0020 
0021 #include <range/v3/detail/prologue.hpp>
0022 
0023 namespace ranges
0024 {
0025     /// \addtogroup group-functional
0026     /// @{
0027     struct equal_to
0028     {
0029         template(typename T, typename U)(
0030             requires equality_comparable_with<T, U>)
0031         constexpr bool operator()(T && t, U && u) const
0032         {
0033             return (T &&) t == (U &&) u;
0034         }
0035         using is_transparent = void;
0036     };
0037 
0038     struct not_equal_to
0039     {
0040         template(typename T, typename U)(
0041             requires equality_comparable_with<T, U>)
0042         constexpr bool operator()(T && t, U && u) const
0043         {
0044             return !equal_to{}((T &&) t, (U &&) u);
0045         }
0046         using is_transparent = void;
0047     };
0048 
0049     struct less
0050     {
0051         template(typename T, typename U)(
0052             requires totally_ordered_with<T, U>)
0053         constexpr bool operator()(T && t, U && u) const
0054         {
0055             return (T &&) t < (U &&) u;
0056         }
0057         using is_transparent = void;
0058     };
0059 
0060     struct less_equal
0061     {
0062         template(typename T, typename U)(
0063             requires totally_ordered_with<T, U>)
0064         constexpr bool operator()(T && t, U && u) const
0065         {
0066             return !less{}((U &&) u, (T &&) t);
0067         }
0068         using is_transparent = void;
0069     };
0070 
0071     struct greater_equal
0072     {
0073         template(typename T, typename U)(
0074             requires totally_ordered_with<T, U>)
0075         constexpr bool operator()(T && t, U && u) const
0076         {
0077             return !less{}((T &&) t, (U &&) u);
0078         }
0079         using is_transparent = void;
0080     };
0081 
0082     struct greater
0083     {
0084         template(typename T, typename U)(
0085             requires totally_ordered_with<T, U>)
0086         constexpr bool operator()(T && t, U && u) const
0087         {
0088             return less{}((U &&) u, (T &&) t);
0089         }
0090         using is_transparent = void;
0091     };
0092 
0093     using ordered_less RANGES_DEPRECATED(
0094         "Repace uses of ranges::ordered_less with ranges::less") = less;
0095 
0096 #if __cplusplus > 201703L && __has_include(<compare>) && \
0097     defined(__cpp_concepts) && defined(__cpp_impl_three_way_comparison)
0098     struct compare_three_way
0099     {
0100         template(typename T, typename U)(
0101             requires three_way_comparable_with<T, U>)
0102         constexpr auto operator()(T && t, U && u) const
0103             -> decltype((T &&) t <=> (U &&) u)
0104         {
0105             return (T &&) t <=> (U &&) u;
0106         }
0107 
0108         using is_transparent = void;
0109     };
0110 #endif // __cplusplus
0111 
0112     namespace cpp20
0113     {
0114         using ranges::equal_to;
0115         using ranges::greater;
0116         using ranges::greater_equal;
0117         using ranges::less;
0118         using ranges::less_equal;
0119         using ranges::not_equal_to;
0120     } // namespace cpp20
0121     /// @}
0122 } // namespace ranges
0123 
0124 #include <range/v3/detail/epilogue.hpp>
0125 
0126 #endif