Boost logo

Boost Users :

From: Joel de Guzman (joel_at_[hidden])
Date: 2008-07-21 12:08:24


Zeljko Vrba wrote:

> Hm, a crazy question: what would happen if I decided to declare
>
> map<pair<int, char>, pair<char, char>, pair<int, double> >

http://www.boost.org/doc/libs/1_35_0/libs/fusion/doc/html/fusion/container/map.html

"A map may contain at most one element for each key."

You'll get a compiler error.

> (note the repeated use of int key).. (That was a rhetoric question, I
> can try that myself :-))

> And now a perceived inconsistency within fusion itself -- vector is clearly a
> map from a set of integers [0..n-1] to types, yet it is not a model of
> associative sequence.

Then you might also perceive an inconsistency within STL too when a
std::vector is not a model of an associative container and a
std::vector is not a map? ;-) This is not the place to complain
about that. Try the C++ committee :-P

> I.e. after having read the documentation for erase_key,
> it turns out that for vectors one has to use erase(), but erase_key() for
> maps.. i'm not saying that it's good or bad, it just strikes me as weird.

erase can be applied to maps too. With erase_key, you supply the key.
With erase, you supply a range or a position.

Regards,

-- 
Joel de Guzman
http://www.boostpro.com
http://spirit.sf.net

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