boost :: hana tuple解压缩可变参数模板实例化

Pab*_*lín 2 c++ boost c++14 boost-hana

此问题相关,我想知道使用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!");
}
Run Code Online (Sandbox Code Playgroud)

eca*_*mur 8

使用template_提升A到一个元函数,然后调用unpack:

using MyStruct = decltype(hana::unpack(my_tuple, hana::template_<A>))::type;
Run Code Online (Sandbox Code Playgroud)

Example.