何か作業をする必要があります:
template<class typeOne>
class X1 : public typeOne
{
X(int b): typeOne(b)
{}
};
template<class typeOne, class typeTwo>
class X2 : public typeOne, public typeTwo
{
X(int b): typeOne(b), typeTwo(b)
{}
};
template<class typeOne, class typeTwo, class TypeThree>
class X3 : public typeOne, public typeTwo, public typeThree
{
X(int b): typeOne(b), typeTwo(b), typeThree(b)
{}
};
か、あなたがオブジェクトごとに数バイトを無駄に喜んでいる場合は、プレースホルダを使用し、唯一の大規模なものを作ることができます。これは、インスタンスごとに使用されていない基本タイプごとに最大で1バイトを無駄にするはずです。
template<int>
class PlaceHolder { PlaceHolder(int){} };
template<
class typeOne,
class typeTwo=PlaceHolder<2>,
class TypeThree=PlaceHolder<3>,
class TypeFour=PlaceHolder<4>,
class TypeFive=PlaceHolder<5>
>
class X :
public typeOne,
public typeTwo,
public typeThree,
public typeFour,
public typeFive
{
X(int b)
: typeOne(b),
typeTwo(b),
typeThree(b),
typeFour(b),
typeFive(b)
{}
X(const X& b)
: typeOne(b),
typeTwo(b),
typeThree(b),
typeFour(b),
typeFive(b)
{}
X& operator=(const X& b) {
typeOne::operator=(b);
typeTwo::operator=(b);
typeThree::operator=(b);
typeFour::operator=(b);
typeFive::operator=(b);}
return *this;
}
};
1良い質問を。途中でミックスインを聞いたことがありますか?たぶん、それはここに適用することができますか、それの変形ですか? – Nawaz
私はこれまで[Boost.MPL](http://www.boost.org/libs/mpl/)でこれまでにしたことがありますが、コードは手軽にできません。今すぐ完全な答え。誰も今までに答えなかったら、今夜私はこれを見直します。ヒントとして、テンプレート引数として2つの 'boost :: mpl :: vector <> 'イテレータを取る特別なミックスインを思い出しています。 – ildjarn
UはどのようにTypeSequenceに関連していますか? –