I want to create a class like below
class enumClass
{
int msdnEnum;
std::string msdnEnumString;
int localEnum;
std::string localEnumString;
}
std::set<enumClass_Objects> enums; // all msdnEnums are unique, same aplies to other three.
enums.find(given_msdnEnum)->FourthVariable;
enums.find(given_localEnum)->FirstVariable;
enums.find(given_msdnEnumStr)->anyVariable;
enums.find(given_localEnumStr)->anyVariable;
I referred boost::multiIndex. But I don’t think that it helps on this case. Can anybody say the way to achieve this?
EDIT
I am not that much good in reading template classes. As for as I am concerning I didn’t find any “find” methods in multiIndex. I saw only sorting out things in that example(the first basic example:link). Suggestions&advices are always welcomed
Here’s a simple example using boost.multi_index:
Tag classes could be used to access the indices by name rather than ordinal index as well, usage of which would look like this:
The difference between the two approaches is purely aesthetic, and of course the tag classes could be named whatever you want rather than
byMsdnEnum, etc. Also note that hashed indices could be used rather than ordered indices, which would give your indices the behavior ofstd::unordered_maprather thanstd::map.