Code: Select all
#include 
struct ArgA {};
struct ArgB {};
struct ArgC {};
struct A
{
A(ArgA& param) {}
};
struct B
{
B(ArgB& param) {}
};
struct C
{
C(ArgC& param) {}
};
template 
struct Alphabet
{
template 
Alphabet(TArgs& ...params) : _alphabet(TLetters(params...)...) {}
std::tuple _alphabet;
};
int main()
{
ArgA argA; ArgB argB; ArgC argC;
Alphabet         alphabet1(argA);              // Compiles
Alphabet      alphabet2(argA, argB);        // Doesn't compile because argA and argB are passed to A, B and C constructors
Alphabet   alphabet3(argA, argB, argC);  // Ditto!
}
Ist das möglich? Möglicherweise eine std::integer_sequence verwenden, um rekursiv über das TArgs-Parameterpaket im Alphabet-Konstruktor zu iterieren? Mein Compiler ist nur C++11-kompatibel.
Danke!
 Mobile version
 Mobile version