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;