Horizon
Loading...
Searching...
No Matches
concepts.hpp
Go to the documentation of this file.
1
3// Range v3 library
4//
5// Copyright Eric Niebler 2013-present
6//
7// Use, modification and distribution is subject to the
8// Boost Software License, Version 1.0. (See accompanying
9// file LICENSE_1_0.txt or copy at
10// http://www.boost.org/LICENSE_1_0.txt)
11//
12// Project home: https://github.com/ericniebler/range-v3
13//
14#ifndef RANGES_V3_FUNCTIONAL_CONCEPTS_HPP
15#define RANGES_V3_FUNCTIONAL_CONCEPTS_HPP
16
17#include <concepts/concepts.hpp>
18
20
21#include <range/v3/detail/prologue.hpp>
22
23namespace ranges
24{
27
28 // clang-format off
29 // WORKAROUND mysterious msvc bug
30#if defined(_MSC_VER) && !defined(__clang__)
33 template<typename Fun, typename... Args>
34 CPP_concept invocable =
35 std::is_invocable_v<Fun, Args...>;
36#else
39 template<typename Fun, typename... Args>
40 CPP_requires(invocable_,
41 requires(Fun && fn) //
42 (
43 invoke((Fun &&) fn, std::declval<Args>()...)
44 ));
47 template<typename Fun, typename... Args>
48 CPP_concept invocable =
49 CPP_requires_ref(ranges::invocable_, Fun, Args...);
50#endif
51
54 template<typename Fun, typename... Args>
55 CPP_concept regular_invocable =
56 invocable<Fun, Args...>;
57 // Axiom: equality_preserving(invoke(f, args...))
58
61 template<typename Fun, typename... Args>
62 CPP_requires(predicate_,
63 requires(Fun && fn) //
64 (
65 concepts::requires_<
66 convertible_to<
67 decltype(invoke((Fun &&) fn, std::declval<Args>()...)),
68 bool>>
69 ));
72 template<typename Fun, typename... Args>
73 CPP_concept predicate =
74 regular_invocable<Fun, Args...> &&
75 CPP_requires_ref(ranges::predicate_, Fun, Args...);
76
79 template<typename R, typename T, typename U>
80 CPP_concept relation =
81 predicate<R, T, T> &&
82 predicate<R, U, U> &&
83 predicate<R, T, U> &&
84 predicate<R, U, T>;
85
88 template<typename R, typename T, typename U>
89 CPP_concept strict_weak_order =
90 relation<R, T, U>;
91 // clang-format on
92
93 namespace cpp20
94 {
98 using ranges::relation;
100 } // namespace cpp20
102} // namespace ranges
103
104#include <range/v3/detail/epilogue.hpp>
105
106#endif
The invocable_ concept.
The invocable concept.
The predicate_ concept.
The predicate concept.
The regular_invocable concept.
The relation concept.
The strict_weak_order concept.
typename Fn::template invoke< Args... > invoke
Evaluate the invocable Fn with the arguments Args.
Definition meta.hpp:541