7 Concepts library [concepts.lib]

7.6 Callable concepts [concepts.lib.callable]

7.6.1 General [concepts.lib.callable.general]

The concepts in this section describe the requirements on function objects ([function.objects]) and their arguments.

7.6.2 Concept Invocable [concepts.lib.callable.invocable]

The Invocable concept specifies a relationship between a callable type ( ISO/IEC 14882:2014 §[func.def]) F and a set of argument types Args... which can be evaluated by the library function invoke ([func.invoke]).

template <class F, class... Args> concept bool Invocable = requires(F&& f, Args&&... args) { invoke(std::forward<F>(f), std::forward<Args>(args)...); // not required to be equality preserving };

Note: Since the invoke function call expression is not required to be equality-preserving ([concepts.lib.general.equality]), a function that generates random numbers may satisfy Invocable. — end note ]

7.6.3 Concept RegularInvocable [concepts.lib.callable.regularinvocable]

template <class F, class... Args> concept bool RegularInvocable = Invocable<F, Args...>;

The invoke function call expression shall be equality-preserving and shall not modify the function object or the arguments ([concepts.lib.general.equality]). [ Note: This requirement supersedes the annotation in the definition of Invocable.  — end note ]

Note: A random number generator does not satisfy RegularInvocable. — end note ]

Note: The distinction between Invocable and RegularInvocable is purely semantic. — end note ]

7.6.4 Concept Predicate [concepts.lib.callable.predicate]

template <class F, class... Args> concept bool Predicate = RegularInvocable<F, Args...> && Boolean<result_of_t<F&&(Args&&...)>>;

7.6.5 Concept Relation [concepts.lib.callable.relation]

template <class R, class T, class U> concept bool Relation = Predicate<R, T, T> && Predicate<R, U, U> && CommonReference< const remove_reference_t<T>&, const remove_reference_t<U>&> && Predicate<R, common_reference_t< const remove_reference_t<T>&, const remove_reference_t<U>&>, common_reference_t< const remove_reference_t<T>&, const remove_reference_t<U>&>> && Predicate<R, T, U> && Predicate<R, U, T>;

Let r be an expression such that decltype((r)) is R, t be an expression such that decltype((t)) is T, u be an expression such that decltype((u)) is U, and C be common_reference_t<const remove_reference_t<T>&, const remove_reference_t<U>&>. Relation<R, T, U> is satisfied only if

  • bool(r(t, u)) == bool(r(C(t), C(u))).

  • bool(r(u, t)) == bool(r(C(u), C(t))).

7.6.6 Concept StrictWeakOrder [concepts.lib.callable.strictweakorder]

template <class R, class T, class U> concept bool StrictWeakOrder = Relation<R, T, U>;

A Relation satisfies StrictWeakOrder only if it imposes a strict weak ordering on its arguments.

The term strict refers to the requirement of an irreflexive relation (!comp(x, x) for all x), and the term weak to requirements that are not as strong as those for a total ordering, but stronger than those for a partial ordering. If we define equiv(a, b) as !comp(a, b) && !comp(b, a), then the requirements are that comp and equiv both be transitive relations:

  • comp(a, b) && comp(b, c) implies comp(a, c)

  • equiv(a, b) && equiv(b, c) implies equiv(a, c)Note: Under these conditions, it can be shown that

    • equiv is an equivalence relation

    • comp induces a well-defined relation on the equivalence classes determined by equiv

    • The induced relation is a strict total ordering.  — end note ]