当我偶然发现这个问题时,我正在试验 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;
GCC 4.5.0在尝试输入模板参数包时给出了一个错误。
基本上,我希望将参数包“存储”在 typedef 中,而不解压缩它。有可能吗?如果没有,是否有什么原因不允许这样做?