Is there a Boost.Bimap alternative in c++11?

前端 未结 2 1070
野性不改
野性不改 2020-12-18 18:01

Is there a usable alternative to Boost\'s bimap in C++0x?

I would like to avoid Boost, but fully embrace C++11. If necessary, a slimmed down version of Boost\'s bima

2条回答
  •  旧时难觅i
    2020-12-18 18:20

    My feeling is a lot of the work that goes into Boost libraries is making them work with other libraries/STL.

    If you don't need that capability, you could just use a class with a std::map and std::map. Then have methods like the following: add(X,Y), remove(X,Y), get_left(X) and get_right(Y).

    If you want to store copies, add(X,Y) could allocate memory, and remove(X,Y) can de-allocate. Also, you can then define a destructor that calls remove(X,Y) on the remainder of the elements.

提交回复
热议问题