문제

typedef boost::bimap<boost::bimaps::vector_of<int>, boost::bimaps::vector_of<float> > bimap_t;
bimap_t mp;
mp.left.insert(bimap_t::left_value_type(2, 2.0f));

Why doesn't this work ? and gives compiler error on insert() It cannot find any insert() that takes bimap_t::left_value_type as argument.

However boost::bimap<boost::bimaps::set_of<int>, boost::bimaps::vector_of<float> > works. looks like the left cannot be vector. but as its bi directional it shouldn't matter

올바른 솔루션이 없습니다

다른 팁

I have never used Boost.Bimap before, but looking through the documentation it seems like the types of the left and right views, and accordingly the member functions you can use, depend on the collections you use as template parameters. You can see here the methods you can use with a vector_of view. You could use:

mp.left.insert(mp.left.end(), bimap_t::left_value_type(2,2.0f));
mp.left.push_back(bimap_t::left_value_type(2,2.0f));

You could also use:

mp.left.push_front(bimap_t::left_value_type(2,2.0f));

but it is not recommended for performance reasons.

PS: If you use bimap<boost::bimaps::set_of<int>, boost::bimaps::vector_of<float> > your insert will work with the left view but it will fail with the right one.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top