Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:27:57

0001 /// \file
0002 // Range v3 library
0003 //
0004 //  Copyright Eric Niebler 2013-present
0005 //
0006 //  Use, modification and distribution is subject to the
0007 //  Boost Software License, Version 1.0. (See accompanying
0008 //  file LICENSE_1_0.txt or copy at
0009 //  http://www.boost.org/LICENSE_1_0.txt)
0010 //
0011 // Project home: https://github.com/ericniebler/range-v3
0012 //
0013 #ifndef RANGES_V3_FUNCTIONAL_ARITHMETIC_HPP
0014 #define RANGES_V3_FUNCTIONAL_ARITHMETIC_HPP
0015 
0016 #include <concepts/concepts.hpp>
0017 
0018 #include <range/v3/detail/prologue.hpp>
0019 
0020 namespace ranges
0021 {
0022     /// \addtogroup group-functional
0023     /// @{
0024     struct plus
0025     {
0026         template<typename T, typename U>
0027         constexpr auto operator()(T && t, U && u) const -> decltype((T &&) t + (U &&) u)
0028         {
0029             return (T &&) t + (U &&) u;
0030         }
0031         using is_transparent = void;
0032     };
0033 
0034     struct minus
0035     {
0036         template<typename T, typename U>
0037         constexpr auto operator()(T && t, U && u) const -> decltype((T &&) t - (U &&) u)
0038         {
0039             return (T &&) t - (U &&) u;
0040         }
0041         using is_transparent = void;
0042     };
0043 
0044     struct multiplies
0045     {
0046         template<typename T, typename U>
0047         constexpr auto operator()(T && t, U && u) const -> decltype((T &&) t * (U &&) u)
0048         {
0049             return (T &&) t * (U &&) u;
0050         }
0051         using is_transparent = void;
0052     };
0053 
0054     struct bitwise_or
0055     {
0056         template<typename T, typename U>
0057         constexpr auto operator()(T && t, U && u) const -> decltype((T &&) t | (U &&) u)
0058         {
0059             return (T &&) t | (U &&) u;
0060         }
0061         using is_transparent = void;
0062     };
0063 
0064     template<typename T>
0065     struct convert_to
0066     {
0067         // clang-format off
0068         template<typename U>
0069         constexpr auto CPP_auto_fun(operator())(U &&u)(const)
0070         (
0071             return static_cast<T>((U &&) u)
0072         )
0073         // clang-format on
0074     };
0075 
0076     template<typename T>
0077     struct coerce
0078     {
0079         constexpr T & operator()(T & t) const
0080         {
0081             return t;
0082         }
0083         /// \overload
0084         constexpr T const & operator()(T const & t) const
0085         {
0086             return t;
0087         }
0088         /// \overload
0089         constexpr T operator()(T && t) const
0090         {
0091             return (T &&) t;
0092         }
0093         T operator()(T const &&) const = delete;
0094     };
0095 
0096     template<typename T>
0097     struct coerce<T const> : coerce<T>
0098     {};
0099 
0100     template<typename T>
0101     struct coerce<T &> : coerce<T>
0102     {};
0103 
0104     template<typename T>
0105     struct coerce<T &&> : coerce<T>
0106     {};
0107     /// @}
0108 } // namespace ranges
0109 
0110 #include <range/v3/detail/epilogue.hpp>
0111 
0112 #endif