简体   繁体   English

将每个类型包装在模板化类中的可变参数模板中

[英]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.

相关问题 在每种类型的可变参数模板上使用 class 初始化元组 - Initialize tuple with class templated on each type of variadic template 为可变参数化模板函数中的每种模板类型调用void函数? - Call void function for each template type in a variadic templated function? 模板化类的可变参数模板 - Variadic Template of Templated Classes 将可变参数模板化类的模板参数解压缩为常量和常量数组 - Unpacking template parameters of a variadic templated class to constants and array of constants 从模板化模板类和可变参数模板中声明“容器”对象 - Declare “container” object from templated template class and variadic templates 如何以简单的方式声明可变参数模板类的类型 - How to declare the type of a variadic templated class in a simple way 嵌套 class 的模板模板参数的可变参数类型模板参数和非类型模板参数如何相互约束? - How do variadic type template parameters and non-type template parameters of the template template parameter of a nested class constrain each other? 包装递归可变参数模板类会更改行为。 为什么? - Wrapping a recursive variadic template class changes behavior. Why? 如何使用可变参数模板转换每种变体类型 - How to cast each variant type with variadic template 如何在现代C ++中基于另一组可变参数模板参数表示可变参数模板类型? - How to represent a variadic templated type based on another group of variadic template arguments in modern C++?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM