Matt S Trentini wrote: [...]
And I was able to do this:
Extract(listOfHcs.begin(), listOfHcs.end(), needToFill, &HandleClass::handle);
And it worked like a charm. needToFill gets filled and I was happy. :)
However we also had containers of _pointers_to_ HandleClasses. So in some cases our vector looked like:
std::vector
listOfHcs; Yet the same code worked! I couldn't, and can't, for the life of me understand what was going on (I expected that I would have to wrap the (*it) in a boost::remove_pointer which worried me because my compiler - MSVC7.0 - doesn't support partial template specialization). Don't get me wrong, I'm happy that it work but can anyone explain what fandangelory is going on inside boost::function (or perhaps it's some C++ magic?) to allow this?
When you construct a boost::function from &HandleClass::handle, what actually gets stored is boost::mem_fn(&HandleClass::handle). See http://www.boost.org/libs/mem_fn/ Even std::vector< boost::shared_ptr<HandleClass> > listOfHcs; will work.