0
votes
1answer
50 views

std::map with function pointers

My issue here is not that I can't map to function pointers, but more the other way around. With my current setup, I can instantiate classes through strings. Now, I'm trying to get strings from class ...
4
votes
3answers
475 views

Is it possible to have a map of {key -> function call} in Scala?

I'm trying to create a class that has a map of keys -> function calls, and the following code is not behaving as I would like it to. class MyClass { val rnd = scala.util.Random def ...
0
votes
1answer
67 views

How to fill and access to std::map<std::pair<enum1, enum2>, funcPtr>?

I would like to know how to fill this type of map and mainly the way to access to the function pointer. The map : enum enum1 { val11, val12, val13 }; enum enum2 { val21, val22, ...
2
votes
1answer
90 views

Adding to function pointer map in dynamic library

The two code sections below show important info. The real work is done in the third code section, main.cpp. // For all files: typedef void (*func_ptr)(Event&); // Event is a class with certain ...
1
vote
2answers
164 views

C Map String to Function

So, I'm making a Unix minishell, and have come to a roadblock. I need to be able to execute built-in functions, so I made a function: int exec_if_built_in(char **args) It takes an array of ...
0
votes
4answers
171 views

c++, stl map of pointers to functions vectors

i seem to have some problem in creating a structure defined as the topic. My objective is to create a sort of event handler, (it doesn't matter if it's good or bad programming,or if it is not ...
3
votes
2answers
243 views

Map of function pointers. Does the function being pointed to have to be static?

I've only just yesterday figured out function pointers, and I am implementing a console/command system in a game engine. I figured using a map with a string key and function pointer value would ...
-1
votes
4answers
534 views

C++: delete values from map in “for each” loop

For a std::vector<double*> v; I can delete the doubles by calling std::for_each(v.begin(), v.end(), (void(*)(void* a))operator delete); Now, if I have std::map<int, double*> m; instead, ...
1
vote
3answers
288 views

how to exit a while loop through a function in C++

Let's assume mf_ptr is a typedef of member function pointer of a class. And we have the flowing code: map<string, mb_ptr> cmd_table; cmd_table["exit"] = &class_name::exit; string cmd; while ...
4
votes
1answer
448 views

Boost fast pool allocator has problems with function pointers?

Is this a Boost bug or am I doing something wrong? #include <map> #include <boost/pool/pool_alloc.hpp> int main() { typedef const std::string key; typedef double* (*value)(const ...
2
votes
5answers
558 views

c++ std::map of heterogeneous function pointers

Is it possible to store pointers to various heterogenous functions like: In the header: int functionA (int param1); void functionB (void); Basically this would the part I don't know how to write: ...
11
votes
4answers
9k views

Using a STL map of function pointers

I developed a scripting engine that has many built-in functions, so to call any function, my code just went into an if .. else if .. else if wall checking the name but I would like to develop a more ...
2
votes
1answer
604 views

How to erase elements in a map with the elements keys in a set?

I have a set stores the keys which I want to delete in a map. I tried the code blow, but it didn't compile. std::set<std::string> keys; std::map<std::string, std::string> mymap; .... ...
1
vote
1answer
164 views

C++: Having trouble using map with a static variable in a class, I get undefined symbol

This is the error I get Undefined symbols: "Config::fmap", referenced from: register_function(unsigned int (*)(unsigned int))in Config.o print_config() in shared.o ld: symbol(s) not ...
2
votes
5answers
83 views

C++: What type do I use for the definition of this map?

So, I have a function pointer defined as: unsigned static int (*current_hash_function)(unsigned int); And I'm trying to make a map of pointers to function names: typedef std::map<fptr_t, ...

1 2
15 30 50 per page