#include <iostream>
#include <tuple>
#include <sstream>
template<int N>
struct A
{
std::string data;
A(std::istream & stream) { stream >> data; }
friend std::ostream& operator<<(std::ostream & out, A<N> const & a)
{
return out << "A"<<N<<"::data = " << a.data;
}
};
typedef A<1> A1;
typedef A<2> A2;
template<typename ...Args>
void test(std::istream & stream)
{
std::tuple<Args...> args { Args(stream)... };
std::cout << std::get<0>(args) << std::endl;
std::cout << std::get<1>(args) << std::endl;
}
int main()
{
std::stringstream ss("A1 A2");
test<A1,A2>(ss);
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dHVwbGU+CiNpbmNsdWRlIDxzc3RyZWFtPgoKdGVtcGxhdGU8aW50IE4+CnN0cnVjdCBBIAp7IAogICAgc3RkOjpzdHJpbmcgZGF0YTsKICAgIEEoc3RkOjppc3RyZWFtICYgc3RyZWFtKSB7IHN0cmVhbSA+PiBkYXRhOyB9CiAgICBmcmllbmQgc3RkOjpvc3RyZWFtJiBvcGVyYXRvcjw8KHN0ZDo6b3N0cmVhbSAmIG91dCwgQTxOPiBjb25zdCAmIGEpIAogICAgewogICAgICAgIHJldHVybiBvdXQgPDwgIkEiPDxOPDwiOjpkYXRhID0gIiA8PCBhLmRhdGE7CiAgICB9Cn07CnR5cGVkZWYgQTwxPiBBMTsKdHlwZWRlZiBBPDI+IEEyOwoKdGVtcGxhdGU8dHlwZW5hbWUgLi4uQXJncz4Kdm9pZCB0ZXN0KHN0ZDo6aXN0cmVhbSAmIHN0cmVhbSkKewogICAgc3RkOjp0dXBsZTxBcmdzLi4uPiBhcmdzIHsgQXJncyhzdHJlYW0pLi4uIH07CiAgICBzdGQ6OmNvdXQgPDwgc3RkOjpnZXQ8MD4oYXJncykgPDwgc3RkOjplbmRsOwogICAgc3RkOjpjb3V0IDw8IHN0ZDo6Z2V0PDE+KGFyZ3MpIDw8IHN0ZDo6ZW5kbDsKfQoKaW50IG1haW4oKQp7CiAgICBzdGQ6OnN0cmluZ3N0cmVhbSBzcygiQTEgQTIiKTsKICAgIHRlc3Q8QTEsQTI+KHNzKTsKfQ==