Мне нужно определить два типа для указанного списка типов: первый - это boost::fusion::vector этих типов, а второй - это boost::fusion::vector, где ссылки и const удаляются для каждого типа в списке типов.
Например, у меня есть int, unsigned & и long const &. Мне нужно определить boost::fusion::vector<int, unsigned &, long const &> и boost::fusion::vector<int, unsigned, long>.
Вот мой код:
struct RemoveRef
{
template <class T>
struct apply
{
using type =
typename std::remove_const<typename std::remove_reference<T>::type>::type;
};
};
template <typename...Args>
struct BasicDefinition
{
typedef typename boost::mpl::vector<Args...> Types;
typedef typename boost::fusion::result_of::as_vector<Types>::type ArgsType;
typedef typename boost::mpl::transform<Types, RemoveRef>::type ValueTypes;
typedef typename boost::fusion::result_of::as_vector<ValueTypes>::type ArgValuesType;
};
Оно работает. Я получаю эти типы как BasicDefinition<>::ArgsType и BasicDefinition<>::ArgValuesType. Но я хочу избавиться от boost::mpl::vector и построить второй тип прямо из первого. Можно ли добиться такого результата?
Что-то вроде:
template <typename...Args>
struct BasicDefinition
{
typedef typename boost::fusion::vector<Args...> ArgsType;
typedef ?????<ArgsTypes, RemoveRef>::type ArgValuesType;
};





Вы можете использовать std::decay_t
template <typename...Args>
struct BasicDefinition
{
using ArgsType = boost::fusion::vector<Args...>;
using ArgValuesType = boost::fusion::vector<std::decay_t<Args>...>;
};