Back to home page

EIC code displayed by LXR

 
 

    


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

0001 
0002 /// \file
0003 // Range v3 library
0004 //
0005 //  Copyright Eric Niebler 2013-present
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_CONCEPTS_HPP
0015 #define RANGES_V3_FUNCTIONAL_CONCEPTS_HPP
0016 
0017 #include <concepts/concepts.hpp>
0018 
0019 #include <range/v3/functional/invoke.hpp>
0020 
0021 #include <range/v3/detail/prologue.hpp>
0022 
0023 namespace ranges
0024 {
0025     /// \addtogroup group-functional
0026     /// @{
0027 
0028     // clang-format off
0029     // WORKAROUND mysterious msvc bug
0030 #if defined(_MSC_VER) && !defined(__clang__)
0031     /// \concept invocable
0032     /// \brief The \c invocable concept
0033     template<typename Fun, typename... Args>
0034     CPP_concept invocable =
0035         std::is_invocable_v<Fun, Args...>;
0036 #else
0037     /// \concept invocable_
0038     /// \brief The \c invocable_ concept
0039     template<typename Fun, typename... Args>
0040     CPP_requires(invocable_,
0041         requires(Fun && fn) //
0042         (
0043             invoke((Fun &&) fn, std::declval<Args>()...)
0044         ));
0045     /// \concept invocable
0046     /// \brief The \c invocable concept
0047     template<typename Fun, typename... Args>
0048     CPP_concept invocable =
0049         CPP_requires_ref(ranges::invocable_, Fun, Args...);
0050 #endif
0051 
0052     /// \concept regular_invocable
0053     /// \brief The \c regular_invocable concept
0054     template<typename Fun, typename... Args>
0055     CPP_concept regular_invocable =
0056         invocable<Fun, Args...>;
0057         // Axiom: equality_preserving(invoke(f, args...))
0058 
0059     /// \concept predicate_
0060     /// \brief The \c predicate_ concept
0061     template<typename Fun, typename... Args>
0062     CPP_requires(predicate_,
0063         requires(Fun && fn) //
0064         (
0065             concepts::requires_<
0066                 convertible_to<
0067                     decltype(invoke((Fun &&) fn, std::declval<Args>()...)),
0068                     bool>>
0069         ));
0070     /// \concept predicate
0071     /// \brief The \c predicate concept
0072     template<typename Fun, typename... Args>
0073     CPP_concept predicate =
0074         regular_invocable<Fun, Args...> &&
0075         CPP_requires_ref(ranges::predicate_, Fun, Args...);
0076 
0077     /// \concept relation
0078     /// \brief The \c relation concept
0079     template<typename R, typename T, typename U>
0080     CPP_concept relation =
0081         predicate<R, T, T> &&
0082         predicate<R, U, U> &&
0083         predicate<R, T, U> &&
0084         predicate<R, U, T>;
0085 
0086     /// \concept strict_weak_order
0087     /// \brief The \c strict_weak_order concept
0088     template<typename R, typename T, typename U>
0089     CPP_concept strict_weak_order =
0090         relation<R, T, U>;
0091     // clang-format on
0092 
0093     namespace cpp20
0094     {
0095         using ranges::invocable;
0096         using ranges::predicate;
0097         using ranges::regular_invocable;
0098         using ranges::relation;
0099         using ranges::strict_weak_order;
0100     } // namespace cpp20
0101     /// @}
0102 } // namespace ranges
0103 
0104 #include <range/v3/detail/epilogue.hpp>
0105 
0106 #endif