]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/metaparse/doc/currying.qbk
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / metaparse / doc / currying.qbk
1 [#currying]
2 [section Currying]
3
4 A [link metafunction template metafunction] supports ['currying] when it accepts
5 less arguments than it normally expects. When less arguments are provided, then
6 it returns a [link metafunction_class template metafunction class] expecting
7 the remaining arguments. That template metafunction class is also expected to
8 support currying.
9
10 For example assuming the following metafunction is given:
11
12 template <class A, class B>
13 struct plus;
14
15 It takes two values, adds them and returns their result. For example:
16
17 static_assert(
18 plus<
19 std::integral_constant<int, 11>,
20 std::integral_constant<int, 2>
21 >::type::value == 13,
22 "This should work"
23 );
24
25 If it supports currying, then the following should also work:
26
27 using inc = plus<std::integral_constant<int, 1>>;
28
29 static_assert(
30 inc::apply<std::integral_constant<int, 12>>::type::value == 13,
31 "This should work"
32 );
33
34 The above example defines the `inc` template metafunction class by calling
35 `plus` with just one argument: the [link boxed_value boxed] `1` value.
36
37 [endsect]
38