假设我有课
template<
typename T1, /*this is probably an integral type*/
T1 Default /*this is a typical value of that integral type*/
> class Foo {};
而这对于一个给定的实例T1
和Default
,说foo
。
我可以decltype(foo)
用来获取完整的类型。
我可以使用一些语法获取值Default
吗?
只需typedef
在课堂上使用。
template<
typename T1,
typename T2
> class Foo
{
public:
typedef T1 type1;
typedef T2 type2;
};
要获得默认设置,您可以使用实际上相同的语法。
template<
typename T1,
T1 Default
> class Foo
{
public:
typedef T1 type1;
static constexpr const T1 default_value = Default;
};
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句