Pointer to members are not used very much but they are really powerful, how have you used them and what’s the coolest things you’ve done?
Edit: This is not so much to list things that are possible, for example listing boost::bind and boost::function aren’t good. Instead maybe a cool usage with them? I know they’re very cool in themselves but that’s not what this is about.
I once was needed to operate with criteria data as pure structure to be able to store the list of all criteria in the queue. And I had to bind the structure with the GUI and other filter elements, etc. So I came up with the solution where pointers to members are used as well as pointers to member functions.
Let’s say you have an
Than you can wrap criteria field and bind with the string representation of the field with
Then you can register all the fields to use whenever you want: GUI, serialization, comparison by field names, etc.
By calling for instance
fields.forEach( serialization );or