#include <iostream>
using namespace std;
auto list = [](auto ...xs) {
return [=](auto access) {
return access(xs...);
};
};
template<bool = true>
struct printer {
template<typename List>
static void run (List xs) {
return xs([](auto first, auto... rest) {
cout << first << " ";
printer<(sizeof...(rest) > 0)>::run(list(rest...));
});
}
};
template<>
struct printer<false> {
template<typename List>
static void run (List xs) {}
};
auto print = [](auto xs) {
return xs([=](auto ...z) {
printer<(sizeof...(z) > 0)>::run(xs);
});
};
int main(int, char**) {
print(list(1, true, "Hello"));
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKYXV0byBsaXN0ID0gW10oYXV0byAuLi54cykgeyAKIHJldHVybiBbPV0oYXV0byBhY2Nlc3MpIHsKICByZXR1cm4gYWNjZXNzKHhzLi4uKTsKIH07IAp9OwoKdGVtcGxhdGU8Ym9vbCA9IHRydWU+CnN0cnVjdCBwcmludGVyIHsKIHRlbXBsYXRlPHR5cGVuYW1lIExpc3Q+CiBzdGF0aWMgdm9pZCBydW4gKExpc3QgeHMpIHsKICByZXR1cm4geHMoW10oYXV0byBmaXJzdCwgYXV0by4uLiByZXN0KSB7CiAgIGNvdXQgPDwgZmlyc3QgPDwgIiAiOwogICBwcmludGVyPChzaXplb2YuLi4ocmVzdCkgPiAwKT46OnJ1bihsaXN0KHJlc3QuLi4pKTsKICB9KTsKIH0KfTsKCnRlbXBsYXRlPD4Kc3RydWN0IHByaW50ZXI8ZmFsc2U+IHsKIHRlbXBsYXRlPHR5cGVuYW1lIExpc3Q+CiBzdGF0aWMgdm9pZCBydW4gKExpc3QgeHMpIHt9Cn07CgphdXRvIHByaW50ID0gW10oYXV0byB4cykgeyAKIHJldHVybiB4cyhbPV0oYXV0byAuLi56KSB7CiAgcHJpbnRlcjwoc2l6ZW9mLi4uKHopID4gMCk+OjpydW4oeHMpOwogfSk7Cn07CgoKaW50IG1haW4oaW50LCBjaGFyKiopIHsKIHByaW50KGxpc3QoMSwgdHJ1ZSwgIkhlbGxvIikpOwogcmV0dXJuIDA7Cn0=