Imported Upstream version 1.64.0
[platform/upstream/boost.git] / libs / hana / benchmark / fold_left / compile.cexpr.unrolled.erb.cpp
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/detail/variadic/foldl1.hpp>
6
7
8 template <typename ...xs>
9 struct list { };
10
11 template <typename T>
12 struct basic_type { using type = T; };
13
14 template <typename T>
15 constexpr basic_type<T> type{};
16
17
18 template <typename F, typename State, typename ...Xs>
19 constexpr auto foldl(F f, State s, list<Xs...> xs)
20 { return boost::hana::detail::variadic::foldl(f, s, type<Xs>...); }
21
22 //////////////////////////////////////////////////////////////////////////////
23
24 struct f {
25     template <typename ...>
26     struct result { };
27
28     template <typename X, typename Y>
29     constexpr auto operator()(X, Y) const
30     { return result<X, Y>{}; }
31 };
32
33 template <int> struct x { };
34 struct state { };
35
36 int main() {
37     constexpr auto xs = list<
38         <%= (1..input_size).map { |i| "x<#{i}>" }.join(', ') %>
39     >{};
40
41     constexpr auto result = foldl(f{}, state{}, xs);
42     (void)result;
43 }