【发布时间】:2011-06-09 03:57:39
【问题描述】:
当我偶然发现这个问题时,我正在尝试使用 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 中,而不是解包。可能吗?如果不是,有什么理由不允许这样做吗?
【问题讨论】:
标签: c++ templates c++11 variadic-templates