1 // Copyright Louis Dionne 2013-2017
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
4 
5 #include <boost/hana/ap.hpp>
6 #include <boost/hana/assert.hpp>
7 #include <boost/hana/config.hpp>
8 #include <boost/hana/equal.hpp>
9 #include <boost/hana/optional.hpp>
10 #include <boost/hana/tuple.hpp>
11 
12 #include <functional>
13 namespace hana = boost::hana;
14 
15 
main()16 int main() {
17     // with tuples
18     static_assert(
19         hana::ap(hana::make_tuple(std::plus<>{}), hana::make_tuple(1, 2),
20                                                   hana::make_tuple(3, 4, 5))
21             ==
22         hana::make_tuple(
23             1 + 3,      1 + 4,      1 + 5,
24             2 + 3,      2 + 4,      2 + 5
25         )
26     , "");
27 
28     // with optional values
29     BOOST_HANA_CONSTEXPR_LAMBDA auto multiply = [](auto a, auto b, auto c) {
30         return a * b * c;
31     };
32 
33     BOOST_HANA_CONSTEXPR_CHECK(
34         hana::ap(hana::just(multiply), hana::just(1),
35                                        hana::just(2),
36                                        hana::just(3))
37             ==
38         hana::just(1 * 2 * 3)
39     );
40 
41     BOOST_HANA_CONSTANT_CHECK(
42         hana::ap(hana::just(multiply), hana::just(1),
43                                        hana::nothing,
44                                        hana::just(3))
45             ==
46         hana::nothing
47     );
48 }
49