私はこの問題につまずいたとき、私はC++ 0xの可変引数テンプレートを使って実験したテンプレートのパラメータパックを展開せずに「格納」することはできますか?
template < typename ...Args >
struct identities
{
typedef Args type; //compile error: "parameter packs not expanded with '...'
};
//The following code just shows an example of potential use, but has no relation
//with what I am actually trying to achieve.
template < typename T >
struct convert_in_tuple
{
typedef std::tuple< typename T::type... > type;
};
typedef convert_in_tuple< identities< int, float > >::type int_float_tuple;
私はテンプレートパラメータパックをtypedefをしようとすると、GCC 4.5.0は私にエラーを与えます。
基本的には、パラメータパックをアンパックせずにtypedefに「格納」したいと思います。出来ますか?そうでない場合は、これが許可されていない理由がいくつかありますか?
ニースは、OPが最初に試したものに非常によく似ています。 –
非常に良い回避策、私は部分的なテンプレートの専門化を使用することについて考えなかった! –
@GMan:簡単な質問...これは役に立ちましたが、部分的に特殊化されたバージョンは実際に 'typedef typename convert_in_tuple :: type type;'であるべきですか、それとも関係ありませんか? –
Jason