]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/benchmark/fold_left/compile.cexpr.recursive.erb.cpp
1 // Copyright Louis Dionne 2013-2016
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)
5 template <typename
...xs
>
9 struct basic_type
{ using type
= T
; };
12 constexpr basic_type
<T
> type
{};
15 template <typename x
, typename
...xs
>
16 constexpr auto head(list
<x
, xs
...>)
19 template <typename x
, typename
...xs
>
20 constexpr auto tail(list
<x
, xs
...>)
21 { return list
<xs
...>{}; }
23 template <typename F
, typename State
, typename X
, typename
...Xs
>
24 constexpr auto foldl(F f
, State s
, list
<X
, Xs
...> xs
)
25 { return foldl(f
, f(s
, head(xs
)), tail(xs
)); }
27 template <typename F
, typename State
>
28 constexpr auto foldl(F
, State s
, list
<>)
31 //////////////////////////////////////////////////////////////////////////////
35 template <typename
...>
38 template <typename X
, typename Y
>
39 constexpr auto operator()(X
, Y
) const
40 { return result
<X
, Y
>{}; }
43 template <int> struct x
{ };
47 constexpr auto xs
= list
<
48 <%= (1..input_size
).map
{ |i
| "x<#{i}>" }.join(', ') %>
51 constexpr auto result
= foldl(f
{}, state
{}, xs
);