Work with function references
Posted
by Ockonal
on Stack Overflow
See other posts from Stack Overflow
or by Ockonal
Published on 2010-06-01T13:18:18Z
Indexed on
2010/06/01
13:23 UTC
Read the original article
Hit count: 166
Hello, I have another one question about functions reference. For example, I have such definition:
typedef boost::function<bool (Entity &handle)> behaviorRef;
std::map< std::string, ptr_vector<behaviorRef> > eventAssociation;
The first question is: how to insert values into such map object?
I tried:
eventAssociation.insert(std::pair< std::string, ptr_vector<behaviorRef> >(eventType, ptr_vector<behaviorRef>(callback)));
But the error:
no matching function for call to ‘boost::ptr_vector<boost::function<bool(Entity&)> >::push_back(Entity::behaviorRef&)’
And I undersatnd it, but can't make workable code.
The second question is how to call such functions? For example, I have one object of behaviorRef, how to call it with boost::bind with passing my own values?
© Stack Overflow or respective owner