boost::mpl::map で、second を抽出


[お題]
boost::mpl::map から second の値を Sequence として抽出したい。

#include <boost/type_traits/is_same.hpp>

#include <boost/mpl/assert.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/map.hpp>
#include <boost/mpl/transform_view.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/at.hpp>

namespace mpl = boost::mpl;


typedef mpl::map<
    mpl::pair<char,  int>,
    mpl::pair<int,   float>,
    mpl::pair<float, char>
> m;
typedef mpl::transform_view<m, mpl::second<mpl::_> >::type seconds;

BOOST_MPL_ASSERT(( boost::is_same<
    mpl::at_c<seconds, 1>::type,
    float
> ));

BOOST_MPL_ASSERT(( mpl::equal<
    seconds,
    mpl::vector<int, float, char>
> ));


mpl::transform_view を使用して、mpl::pair から mpl::second に変換しています。
と、書いてはみたもののすでにライブラリ側で用意されてるような気がする。


[boost]
ver 1.45.0