Boost logo

Boost Users :

Subject: Re: [Boost-users] mpl and set of maps
From: Peter Foelsche (foelsche_at_[hidden])
Date: 2011-03-21 10:26:52


"Peter Foelsche" <foelsche_at_[hidden]> wrote in message
news:im65n2$u72$1_at_dough.gmane.org...
I wrote my own insert to overcome this problem.

Extracting the elements, sorting them and then inserting them back.

I think this should either be fixed or documented.

Or maybe there should be some option to enable what I want to do.

(Stupid "smart" formating coming from Windows Mail -- functionality to
destroy all formating)

template<typename T0, typename T1>

struct compare

{ typedef typename boost::mpl::less<

typename T0::first,

typename T1::first

>::type type;

};

template<typename MAP, typename VALUE>

struct insert1

{ typedef typename boost::mpl::key_type<MAP, VALUE>::type KEY;

typedef typename boost::mpl::erase_key<MAP, KEY>::type MAP1;

typedef typename boost::mpl::accumulate<

MAP1,

boost::mpl::vector<>,

boost::mpl::push_back<boost::mpl::_1, boost::mpl::_2>

>::type VECTOR;

typedef typename boost::mpl::sort<

typename boost::mpl::push_back<

VECTOR,

VALUE

>::type,

compare<boost::mpl::_1, boost::mpl::_2>

>::type SORTED;

typedef typename boost::mpl::accumulate<

SORTED,

boost::mpl::map<>,

boost::mpl::insert<boost::mpl::_1, boost::mpl::_2>

>::type type;

};


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net