I have following:
struct foo_and_number_helper {
std::string foo;
uint64_t number;
};
struct foo_and_number {};
struct bar {};
using my_bimap = boost::bimaps::bimap<
boost::bimaps::unordered_set_of<boost::bimaps::tagged<foo_and_number_helper, foo_and_number>>,
boost::bimaps::multiset_of<boost::bimaps::tagged<std::string, bar>>
>;
my_bimap instance;
and I want to be able to call find and erase methods like this:
instance.left.find("foo")
instead of instance.left.find({"foo",1})
and
instance.left.erase("foo")
instead of instance.left.erase({"foo",1})
.
I just want to use only the "foo" part of "foo_and_number_helper" instead of both parts for methods find and erase called from the left side. How to achieve that? I tried to read the bimap implementation, but it's still hard for me to do it.
I already asked more broad question: Is C++ bimap possible with one side of view having different key than other side of the view value? How to do that?
and from the comments I have to override operator <
, but I am not even sure about that and if it's enough.
I'd go with
boost::multi_index_container
overboost::bimap
here.You would then use it like
I.e. rather than having a
left
andright
view, you have any number of views