[英]Wrapping each type in a variadic template in a templated class
Given a variadic template Types...
, I would like to store A<>
for each of the types in the pack. 给定一个可变参数模板Types...
,我想为包中的每个类型存储A<>
。 This could be done in a tuple of A<>
's, but I'd need to programmatically derive the type of said tuple. 这可以在A<>
的元组中完成,但我需要以编程方式派生所述元组的类型。
Is such a thing even possible in c++11/14/17? 在c ++ 11/14/17中这样的事情是否可能?
template <class T> class A { };
template <class... Types>
class B
{
// A tuple of A<>'s for each type in Types...
std::tuple<A<Type1>, A<Type2>, ...> data;
};
Simply with: 只需:
template <class... Types>
class B
{
std::tuple<A<Types>...> data;
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.