Sensei
Dear all,
I am experimenting with MultiIndex, and I am happy with my custom classes.
Now I am wondering, can I index integers without a custom class?
For instance, say we have a 32 bit unsigned integer, how can I index these with respect to the MSB or LSB? [...]
You can define a function that does the MSB/LSB extraction and either
pack it as a custom key extractor:
http://www.boost.org/libs/multi_index/doc/
tutorial/key_extraction.html#user_defined_key_extractors
or plug it into boost::multi_index::global_fun:
http://www.boost.org/libs/multi_index/doc/
tutorial/key_extraction.html#global_fun
The following example shows the latter approach for a multi_index_container
of uint32_t's --you can easily adapt this to your particular scenario
where the uint32_t's are members of a larger class.
#include
multi_t;
int main()
{
multi_t m={0x00030000ul,0x00020001ul,0x00010002ul,0x00000003ul};
std::cout<