#include <map> #include <set>
typedef std::map
CInt2IntMap; typedef std::set CIntSet; static CInt2IntMap convert(const CIntSet &_r) { CInt2IntMap s; for (CIntSet::const_iterator p = _r.begin(); p != _r.end(); ++p) s.insert(std::make_pair(*p, s.size())); return s; }
Thanks Adam.
I found my own solution meanwhile.
I tried both, yours and mine.
Very slowly I'm getting used to this programming style (grin).
The compiler error messages are not very helpful.
Kind Regards
Peter
#include
CFirstSet;
template<typename CFirstSet> struct CMyConvert:boost::mpl::accumulate< CFirstSet, boost::mpl::map<>, boost::mpl::lambda< boost::mpl::insert< boost::mpl::_1, boost::mpl::pair< boost::mpl::_2, boost::mpl::sizeboost::mpl::_1 > > >::type
::type { };
template<typename InputSeq>
struct CConvert : boost::mpl::transform<
InputSeq,
boost::mpl::range_c<
long,
0,
boost::mpl::size<InputSeq>::value
>,
boost::mpl::pair
::type { };
typedef boost::mpl::map<
boost::mpl::pair<
boost::mpl::int_<3>,
boost::mpl::integral_c
CMap1;
typedef boost::mpl::map< boost::mpl::pair< boost::mpl::int_<3>, boost::mpl::long_<0> >, boost::mpl::pair< boost::mpl::int_<1>, boost::mpl::long_<1> >
CMap2;
template<typename T>
struct wrap
{
};
struct CPrintType
{ template<typename T>
void operator()(wrap<T>) const
{ std::cout << typeid(T).name() << "\n";
}
};
int main(int , char **)
{
BOOST_MPL_ASSERT((
boost::mpl::equal_to<
boost::mpl::at<
CConvert<CFirstSet>,
boost::mpl::int_<1>
>::type,
boost::mpl::integral_c