using boost::mem_fn result as a parameter?
I'm new to boost::bind and boost::mem_fn. I've read the documentation
and I think I understand what they do, but I'm not sure how to use them
to accomplish my task.
I have a class that contains several vectors in a map. I want to put a
"foreach" method on the class that will callback an arbitrary member
function, of an arbitrary class, for each item in the vector.
I'm stuck on the signature of that method.
A quick sketch of the structure:
class VectorContent
{
public:
void dosomething();
// there are bunches more, which is why I don't
// want a foreach for every possible choice.
};
class VectorHolder
{
std::map
On Thursday 04 September 2003 06:26 pm, Mark Sizer wrote:
I'm new to boost::bind and boost::mem_fn. I've read the documentation and I think I understand what they do, but I'm not sure how to use them to accomplish my task.
I have a class that contains several vectors in a map. I want to put a "foreach" method on the class that will callback an arbitrary member function, of an arbitrary class, for each item in the vector.
I'm stuck on the signature of that method. [snip]
void VectorHolder::foreach( std::string& rsName, WHAT? callback ) { std::vector<VectorContent>& rvect = rvectGet( rsName ); std::for_each( rvect.begin(), rvect.end(), callback ); }
You can write it the signature like this:
void VectorHolder::foreach( std::string& rsName,
const boost::function
participants (2)
-
Douglas Gregor
-
Mark Sizer