template struct result { }; constexpr struct { template constexpr result operator()(State, X) const { return {}; } } f{}; constexpr struct { } state{}; template struct x { }; int main() { auto go = foldl( <%= (['f', 'state'] + (0...x).map { |n| "x<#{n}>{}" }).join(', ') %> ); }