boost mpl から fusion へ変換する

こんな感じですかね。

#include <type_traits>
#include <boost/fusion/container/vector.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/deque.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/at.hpp>

namespace mpl = boost::mpl;
namespace fusion = boost::fusion;

template<class T, std::size_t step = 0, bool = step >= mpl::size<T>::type::value, class... Types>
struct mpl_to_fusion {
    using type = fusion::vector<Types...>;
};

template<class T, std::size_t step, class... Types>
struct mpl_to_fusion<T, step, false, Types...> :
mpl_to_fusion<T, step + 1, step >= mpl::size<T>::type::value - 1, Types..., typename mpl::at_c<T, step>::type>
{};

int main()
{
    using mplvec = mpl::vector<int, char, float>;
    using mpllist = mpl::list<int, char, float>;
    using mpldeq = mpl::deque<int, char, float>;
    
    using fusionvec = fusion::vector<int, char, float>;
    
    static_assert(std::is_same<mpl_to_fusion<mplvec>::type, fusionvec>::value, "");
    static_assert(std::is_same<mpl_to_fusion<mpllist>::type, fusionvec>::value, "");
    static_assert(std::is_same<mpl_to_fusion<mpldeq>::type, fusionvec>::value, "");
}

boost.fusionは今までで初めて使いました。 boostは正直使ったことないものが多くてまだ全然分からないですね。

とりあえず上手く動いてるみたい。

追記

@iorateさんがとても有益な事をおっしゃっていたので掲載しておきます。

コードも引用

#include <boost/mpl/back_inserter.hpp>
#include <boost/mpl/copy.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/fusion/include/mpl.hpp> // Adapt Fusion sequences as MPL ones
#include <boost/fusion/include/vector.hpp>
 
namespace mpl = boost::mpl;
namespace fusion = boost::fusion;
 
template <class Seq>
using mpl_to_fusion = typename mpl::copy<Seq, mpl::back_inserter<fusion::vector<>>>::type;
 
mpl_to_fusion<mpl::vector<int, char, float>> const vec{42, 'A', 2.818};

ということで、厄介なTMPを使わなくても共通のインタフェースとしてmplとfusionが扱えるので、ライブラリの機能を利用してとてもシンプルに同様の機能を実装出来るようです。
素晴らしいですね。