Blame view

3rdparty/boost_1_81_0/libs/metaparse/doc/currying.qbk 1.07 KB
73ef4ff3   Hu Chunming   提交三方库
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
  [#currying]
  [section Currying]
  
  A [link metafunction template metafunction] supports ['currying] when it accepts
  less arguments than it normally expects. When less arguments are provided, then
  it returns a [link metafunction_class template metafunction class] expecting
  the remaining arguments. That template metafunction class is also expected to
  support currying.
  
  For example assuming the following metafunction is given:
  
    template <class A, class B>
    struct plus;
  
  It takes two values, adds them and returns their result. For example:
  
    static_assert(
      plus<
        std::integral_constant<int, 11>,
        std::integral_constant<int, 2>
      >::type::value == 13,
      "This should work"
    );
  
  If it supports currying, then the following should also work:
  
    using inc = plus<std::integral_constant<int, 1>>;
    
    static_assert(
      inc::apply<std::integral_constant<int, 12>>::type::value == 13,
      "This should work"
    );
  
  The above example defines the `inc` template metafunction class by calling
  `plus` with just one argument: the [link boxed_value boxed] `1` value.
  
  [endsect]