1 /*=============================================================================
2 Copyright (c) 2017 Paul Fultz II
3 pointfree.cpp
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 ==============================================================================*/
7 /*=============================================================================
8 Copyright (c) 2016 Paul Fultz II
9 pointfree.cpp
10 Distributed under the Boost Software License, Version 1.0. (See accompanying
11 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
12 ==============================================================================*/
13
14 #include "example.h"
15
16 using namespace boost::hof;
17
18 BOOST_HOF_STATIC_FUNCTION(simple_print) = BOOST_HOF_LIFT(std::ref(std::cout) << _);
19 BOOST_HOF_STATIC_FUNCTION(print) = proj(simple_print);
20 BOOST_HOF_STATIC_FUNCTION(print_lines) = proj(flow(simple_print, _ << std::integral_constant<char, '\n'>{}));
21 BOOST_HOF_STATIC_FUNCTION(max) = fold(BOOST_HOF_LIFT(std::max));
22
main()23 int main()
24 {
25 simple_print("Hello\n");
26 print("Hello", "World\n");
27 print_lines("Hello", "World");
28
29 auto n = max(1, 2, 4, 3); // Returns 4
30 auto m = max(0.1, 0.2, 0.5, 0.4); // Returns 0.5
31
32 print_lines(n, m);
33 }
34