Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 可以使用Boost.Hana将std::数组解包到非类型模板参数包中吗? 模板 结构S{}; constexpr auto a=std::array{0,1,2};_C++_Template Meta Programming_Boost Hana - Fatal编程技术网

C++ 可以使用Boost.Hana将std::数组解包到非类型模板参数包中吗? 模板 结构S{}; constexpr auto a=std::array{0,1,2};

C++ 可以使用Boost.Hana将std::数组解包到非类型模板参数包中吗? 模板 结构S{}; constexpr auto a=std::array{0,1,2};,c++,template-meta-programming,boost-hana,C++,Template Meta Programming,Boost Hana,我想将a的元素作为模板参数解压缩到S。就是,S 可能的C++2a实现: 模板 constexpr decltype(自动)解包() { constexpr auto size=std::tuple\u size\u v; 返回[](标准::索引_序列){ 返回模板{}; }(std::make_index_sequence{}); } 使用Result=decltype(unpack()); 在Boost.Hana中有一种惯用的方法来实现这一点吗?我认为自然的异构类型Boost.Hana方法是

我想将
a
的元素作为模板参数解压缩到
S
。就是,<代码>S

可能的C++2a实现:

模板
constexpr decltype(自动)解包()
{
constexpr auto size=std::tuple\u size\u v;
返回[](标准::索引_序列){
返回模板{};
}(std::make_index_sequence{});
}
使用Result=decltype(unpack());

在Boost.Hana中有一种惯用的方法来实现这一点吗?

我认为自然的异构类型Boost.Hana方法是将
std::array
元素提升到
Hana::integral_constant
s的
Hana::tuple
中,并将类模板提升到元函数:

模板
结构S{};
使用名称空间boost::hana::literals;
constexpr auto a=boost::hana::make_tuple(0_c,1_c,2_c);
模板
constexpr自动提升非类型模板=[](Ts…){
返回boost::hana::type_c;
};
使用Result=decltype(boost::hana::unpack(a,lift\u non\u type\u模板))::type;