// Copyright Louis Dionne 2013-2017 // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) template struct list { }; template struct basic_type { using type = T; }; template constexpr basic_type type{}; template constexpr auto head(list) { return type; } template constexpr auto tail(list) { return list{}; } template constexpr auto foldl(F f, State s, list xs) { return foldl(f, f(s, head(xs)), tail(xs)); } template constexpr auto foldl(F, State s, list<>) { return s; } ////////////////////////////////////////////////////////////////////////////// struct f { template struct result { }; template constexpr auto operator()(X, Y) const { return result{}; } }; template struct x { }; struct state { }; int main() { constexpr auto xs = list< <%= (1..input_size).map { |i| "x<#{i}>" }.join(', ') %> >{}; constexpr auto result = foldl(f{}, state{}, xs); (void)result; }