
On 2/24/07, Thorsten Ottosen <thorsten.ottosen@dezide.com> wrote:
Matias Capeletto wrote:
On 2/23/07, Thorsten Ottosen <thorsten.ottosen@dezide.com> wrote:
Maybe I missed how one would use this view. How exactly (and which
in the documentation?)
Maybe I have introduce noise here. The left view is the bidirectional mapping view from the left, the one obtained with bm.left
bimap<X,Y>::left_map_type is signature compatible with std::map<X,Y>. bimap<X,Y>::left_map_type::value_type is signature-compatible with std::pair<X,Y> and bimap<X,Y>::right_map_type::value_type is signature-compatible with std::pair<Y,X>
So you can use this view or the right one with generic algorithms
Matias Capeletto wrote: page that need
first/second members.
I missed that. It seems like there is less to worry about then :-)
Take this example:
typedef bimap<std::string,int> results_bimap; typedef results_bimap::relation position;
results_bimap results; results.insert( position("Argentina" ,1) ); results.insert( position("Spain" ,2) ); results.insert( position("Germany" ,3) ); results.insert( position("France" ,4) );
I could not find any documentation on direct members of a bimap. Should it read results.left.insert()???
No, there is some confusion here. The documentation will have to be changed to help grasp the essence of bimap easier. Fernando Cacciola has proposed some useful changes to the docs.
I looked in the reference section under bimap and it only stated constructors and types. Have I found some old documentation on the net somehow? Anyway, I think I get it.
std::make_pair() aside, you are often forced to constructing a pair object, only to copy its data once again upon insertion into the map.
Can you give an example?
Well, the rvalue position objects created above is a good example: 1. creare rvalue string (non-trivial) and int (trivial) arguments 2. copy string and int in position constructor 3. upon insertion, copy string and int again So the above takes 1 constructor call 2 copy-constructor calls per argument, Removing 1 copy-constructor call is the goal here. -Thorsten