C++ 将boost::parameter_类型转换为std::tuple

C++ 将boost::parameter_类型转换为std::tuple,c++,boost,C++,Boost,我相信有一些方法可以通过MPL和fusion做到这一点,但由于我是boost新手,所以很难弄清楚 不管元组是std还是boost,我试图最终实现的是: template<T> void some_func() { // declare a tuple contains types of which in boost::function_types::parameter_types<T> // insert values to the tuple /

我相信有一些方法可以通过MPL和fusion做到这一点,但由于我是boost新手,所以很难弄清楚

不管元组是std还是boost,我试图最终实现的是:

template<T>
void some_func()
{
    // declare a tuple contains types of which in boost::function_types::parameter_types<T>
    // insert values to the tuple
    // call std::apply()
}
模板
使某些函数无效()
{
//声明元组包含boost::function\u types::parameter\u types中的类型
//向元组插入值
//调用std::apply()
}

我尝试过使用fold,但没有弄清楚第三个模板参数应该是什么。

还没有测试过它,但以下应该可以:

#include <type_traits>
#include <tuple>
#include <boost/mpl/at.hpp> // For at

namespace detail {
  template<class ParamSequence, std::size_t ...Indices>
  auto unpack_params(ParamSequence, std::index_sequence<Indices...>) -> std::tuple<boost::mpl::at<ParamSequence, Indices>...>;
}

template<class Function>
using param_tuple_t = decltype(detail::unpack_params(boost::function_types::parameter_types<Function>(), std::make_index_sequence<boost::function_types::function_arity<Function>::value>()>()));
#包括
#包括
#包括//For at
名称空间详细信息{
模板
自动解包_参数(ParamSequence,std::index_sequence)->std::tuple;
}
模板
使用param_tuple_t=decltype(detail::unpack_params(boost::function_types::parameter_types(),std::make_index_sequence()>());

使用
at_c
而不是
at
并使用
::键入
有效。谢谢!