Original Post
Howdy! I'm about 3 weeks into my adventure with C++ and I'm already onto advanced topics like function pointers :) Go me! I'm starting to think they're a little too advanced though, because I'm still having trouble doing what I want. Ideally I'd like to have a multimap of function pointers->vector of strings, but if I can at least get a map of vectors->function pointers I'll be happy (for now). I think the problems are related to the same misunderstanding I have about function pointers and maps though. Okay, here's some snippets of code. Help me out and enlighten me if you can! Defining the map:
typedef bool(*action_handler_func)( const vector_string_t * );
typedef multimap< action_handler_func, vector_string_t > map_func_to_vector_string_t;
class Action
{
public:
static bool action_scroll_list (const vector_string_t *v);
map_func_to_vector_string_t action;
....
Inside of a static member function of the Action class:
bool Action::build_actions_callback(const boost::match_results<std::string::const_iterator>& in)
{
vector_string_t v;
v = explode(in.str(2), ",");
string s = in.str(1);
if (s == "SCROLL_LIST")
{
/*
Errors on the next line with:
error C2676: binary '[': 'map_func_to_vector_string_t' does
not define this operator or a conversion to a type
acceptable to the predefined operator
*/
me->action[(&action_scroll_list)] = v;
}
The action_scroll_list function looks like this:
bool Action::action_scroll_list (const vector_string_t *v)
{
return true;
}
I've tried a bunch of variations on this, like creating a string->function_pointer map, a vector of function pointers, and a map of function_pointers->string and nothing seems to work. They all error with the same error message, whenever I try and assign a function pointer. What am I missing? --Steve