For the below class, how do I represent the pointer to the member variable qux of one of the instances of Bar?
struct Foo {
struct Bar {
int qux;
} bar1, bar2;
};
This is needed when I use the boost::multi_index container and need to use qux as the key, which is needed in the key extractor
template<class Class,typename Type,Type Class::*PtrToMember>
struct boost::multi_index::member
I am assuming the intention is to create a boost multi_index container of
Foos and usequxas the key. Thoughquxisn't a member ofFoo, you can achieve this by indexing on the memberFoo::bar1and providing a custom comparison predicate for the ordered index. For example, if you are trying to create anordered_uniquekey, you would write it like this:where
compare_foo_baris a friend ofFoo::Barand is defined as need: