Debian Codegraph @

yo/advancedtemplates/concepts/multipleparams.yo

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