this question有关,我想知道是否可以使用boost::hana以一种直接的方式实现这样的事情:

#include <boost/hana.hpp>
#include <boost/hana/unpack.hpp>

namespace hana = boost::hana;

template<typename ... T>
struct A {};

int main() {

  auto my_tuple = hana::tuple_t<int, double, float>;

  // Is there any way to unpack my_tuple as template arguments for A?
  // Something like
  using MyStruct = A<hana::unpack_types(my_tuple)...>;

  static_assert(std::is_same<MyStruct, A<int, double, float>>::value, "Ooops!");
}

最佳答案

使用 template_ A boost 为一个元函数,然后调用 unpack :

using MyStruct = decltype(hana::unpack(my_tuple, hana::template_<A>))::type;

关于c++ - boost::hana tuple解压缩用于可变参数模板实例化,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/38008302/

10-14 09:36