2 [section Lazy template metafunction]
4 A ['lazy template metafunction] is a [link metafunction template metafunction]
5 that accepts [link nullary_metafunction nullary metafunction]s as arguments,
6 that need to be evaluated first to get the value of the argument.
8 For example here is a `plus` metafunction for `int` values:
10 template <class A, class B>
12 std::integral_constant<int, A::value + B::value>
15 This metafunction takes two [link boxed_value boxed] numbers as arguments,
16 unboxes them, adds their values and boxed the result again.
18 It works when it is called with boxed numbers. For example:
22 std::intgeral_constant<int, 2>,
23 std::integral_constant<int, 2>
28 However, when it is called with a nullary metafunction returning the boxed
31 struct nullary_metafunction_returning_2
33 using type = std::integral_constant<int, 2>;
37 plus<nullary_metafunction_returning_2, nullary_metafunction_returning_2>::type
39 So `plus` is ['not] a lazy template metafunction. To make it lazy, it has to
40 evaluate its arguments before using them:
42 template <class A, class B>
44 std::integral_constant<int, A::type::value + B::type::value>
47 Note that it uses `A::type::value` and `B::type::value` instead of `A::value`
48 and `B::value`. It works when it is called with nullary metafunctions as well:
52 nullary_metafunction_returning_2,
53 nullary_metafunction_returning_2
58 Because it works with nullary metafunctions as arguments, it is a lazy template