How can I use std::make_tuple if the execution order of the constructors is important?
For example I guess the execution order of the constructor of class A and the
I believe the only way to manually unroll the definition. Something like the following might work. I welcome attempts to make it nicer though.
#include
#include
struct A { A(std::istream& is) {}};
struct B { B(std::istream& is) {}};
template
class Parser
{ };
template
class Parser
{
public:
static std::tuple parse(std::istream& is) {return std::make_tuple(T(is)); }
};
template
class Parser
{
public:
static std::tuple parse(std::istream& is)
{
A t(is);
return std::tuple_cat(std::tuple(std::move(t)),
Parser::parse(is));
}
};
int main()
{
Parser::parse(std::cin);
return 1;
}