1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
Most predefined concepts expecting more than two parameters are variadic
(cf. section ref(CONPACK)).
itemization(
ittq(constructible_from)(requires a LHS type and a variadic template parameter
representing the types from which LHS can be constructed (which may be
empty if a default constructor is suppported). Here is an example:
verbinsert(//constructible examples/constructible.cc)
)
ittq(equivalence_relation)(this concept defines three template type
parameters. It is a synonym of the concept tt(std::relation) (see below);)
ittq(invocable)(requires a LHS type and a variadic template parameter
representing the types which are forwared as arguments to the function or
functor specified as tt(invocable's) first argument. Here is an example:
verbinsert(//invocable examples/invocable.cc)
)
ittq(predicate)(requires a LHS type which is a predicate (functor or function
returning a tt(bool) value), expecting arguments of the variadic template
parameter RHS. Here is an example:
verbinclude(//predicate examples/predicate.cc)
)
ittq(regular_invocable)(synonym of tt(invocable);)
ittq(relation)(this concept defines three template type parameters. The first
parameter is a predicate whose function call operator expects
two arguments. The arguments are of the types of the second and/or third
template type parameters (any combination, any order).
For example, the requirements of the tt(std::relation) concept are
satisfied if the predicate's first template argument is tt(std::less), the
second argument is tt(int) and the third argument is tt(double).
In the following example tt(struct Less) is a functor comparing the
two arguments of its function call operator. Next, the function tt(cmp)
accepts such a struct type as predicate, verifying that the predicate and
the arguments that are passed to the function satisfy the requirements of
the tt(std::relation) concept. If so the functor's return value is
returned.
Finally, in main tt(cmp) is first called with tt(int) and tt(double)
arguments (which succeeds) and then with an tt(int) and a NTBS arguments:
for the second call the constraints are not satisfied as tt(ints) and
tt(NTBSs) can't be compared, and consequently compilation fails:
verbinclude(//relation examples/relation.cc);)
ittq(strict_weak_order)(this concept defines three template type
parameters. The first parameter is the type of a predicate whose function
call operator expects two arguments. The arguments are of the types of the
second and/or third template type parameters (any combination, any
order). The concept is satisfied if the predicate can verify that a strict
weak order applies to its argument types. A relation is a strict weak
ordering if
itemization(
it() the predicate returns false if an object is compared to itself;
it() the relation is transitive: if tt(pred(one, two)) and tt(pred(two,
three)) are both true, then tt(pred(one, three)) is also true;
))
)
|