Matias Capeletto wrote:
On Wed, Nov 25, 2009 at 6:08 PM, Edward Diener
wrote: ... you have just wrote down here why it is not a good idea to provide this constructor. Not only it breaks the symmetry, the real problem is that following your idea of automatic conversion between pairs and relations we bump into ambiguities. Imagine you now have a bimap, and you use your constructor with a map... it is not clear which side is the left and which side is the right. Are you saying that if I insert map items on the left side of a bimap I can not access them from the right side of the bimap, or vice versa ? That would seem to make the bimap fairly useless. If not, in your example of bimap and map it should make no difference whatever into which side the map
Matias Capeletto wrote: pairs are originally inserted.
I am not saying that. The problem is that If you have a std::map
m; with the elements (1,10), (2,20), (3,30), (4,40), and you code: boost::bimap
bm( m ); It is ambiguous, you just have to choose to view the map as the left view of the bimap or as the right one, and the only way to get out of this problem is to give one of the views priority over the other one which goes against the design of the library... or to ask the users to explicitly show their intention:
boost::bimap
bm(); bm.left.insert( m.begin(), m.end() );
But if I do the above I can still access the bimap from either the left or right views. So it little matters which one I use to actually insert my map entries. Whether I go: bm.left.insert( m.begin(), m.end() ); or bm.right.insert( m.begin(), m.end() ); ,when both types are the same, is totally irrelevant to further use of the bimap. Is this not correct ? So therefore if you create a bimap constructor which takes a map, and both types are exactly the same, it is irrelevant if internally you use bm.left.insert( m.begin(), m.end() ); or bm.right.insert( m.begin(), m.end() ); to populate the bimap. Therefore your argument that having to decide how to populate the bimap from a map, when both types are the same, is a reason not to create a constructor which takes a map is not valid to me.