namespace detail
{
template<typename... Ts>
struct do_foo;
template<typename T, typename... Ts>
struct do_foo<T, Ts...>
{
static void call()
{
T::foo();
do_foo<Ts...>::call();
}
};
template<typename T>
struct do_foo<T>
{
static void call()
{
T::foo();
}
};
}
template<typename... Ts>
void do_foo()
{
detail::do_foo<Ts...>::call();
}
#include <iostream>
struct X { static void foo() { std::cout << "X::foo()" << std::endl; }; };
struct Y { static void foo() { std::cout << "Y::foo()" << std::endl; }; };
struct Z { static void foo() { std::cout << "Z::foo()" << std::endl; }; };
int main()
{
do_foo<X, Y, Z>();
}
ICAgIG5hbWVzcGFjZSBkZXRhaWwKICAgIHsKICAgICAgICB0ZW1wbGF0ZTx0eXBlbmFtZS4uLiBUcz4KICAgICAgICBzdHJ1Y3QgZG9fZm9vOwoKICAgICAgICB0ZW1wbGF0ZTx0eXBlbmFtZSBULCB0eXBlbmFtZS4uLiBUcz4KICAgICAgICBzdHJ1Y3QgZG9fZm9vPFQsIFRzLi4uPgogICAgICAgIHsKICAgICAgICAgICAgc3RhdGljIHZvaWQgY2FsbCgpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIFQ6OmZvbygpOwogICAgICAgICAgICAgICAgZG9fZm9vPFRzLi4uPjo6Y2FsbCgpOwogICAgICAgICAgICB9CiAgICAgICAgfTsKCiAgICAgICAgdGVtcGxhdGU8dHlwZW5hbWUgVD4KICAgICAgICBzdHJ1Y3QgZG9fZm9vPFQ+CiAgICAgICAgewogICAgICAgICAgICBzdGF0aWMgdm9pZCBjYWxsKCkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgVDo6Zm9vKCk7CiAgICAgICAgICAgIH0KICAgICAgICB9OwogICAgfQoKICAgIHRlbXBsYXRlPHR5cGVuYW1lLi4uIFRzPgogICAgdm9pZCBkb19mb28oKQogICAgewogICAgICAgIGRldGFpbDo6ZG9fZm9vPFRzLi4uPjo6Y2FsbCgpOwogICAgfQoKICAgICNpbmNsdWRlIDxpb3N0cmVhbT4KCiAgICBzdH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