I need to define two types for specified typelist: first is boost::fusion::vector
of these types and second is boost::fusion::vector
where references and const
are removed for each type in type list.
For example, I have int
, unsigned &
and long const &
. I need to define boost::fusion::vector<int, unsigned &, long const &>
and boost::fusion::vector<int, unsigned, long>
.
Here is my code:
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;
};
It works. I get these types as BasicDefinition<>::ArgsType
and BasicDefinition<>::ArgValuesType
. But I want to get rid of boost::mpl::vector
s and build second type directly from the first one. Is it possible to achieve such result?
Something like:
template <typename...Args>
struct BasicDefinition
{
typedef typename boost::fusion::vector<Args...> ArgsType;
typedef ?????<ArgsTypes, RemoveRef>::type ArgValuesType;
};
You might use std::decay_t
template <typename...Args>
struct BasicDefinition
{
using ArgsType = boost::fusion::vector<Args...>;
using ArgValuesType = boost::fusion::vector<std::decay_t<Args>...>;
};