I want use a std::function in std::map, follow the code:
#include <functional>
#include <map>
class MyClass {
...
std::function<void()> Callback();
std::map<std::string, Callback> my_map;
...
}
std::map receive a Key and a T, but a not knew whats mistake in my code, him no access the std::map functions(insert, end, find...)
Using typedef, him run.But why std::function not run?
I firts place: whats the problem?
Before: How to solve it? --code sample please =D;
Thanks by help
You've declared Callback
to be a function (returning std::function
), not a type. You need a type to declare what you're storing in the map. I guess you want
typedef std::function<void()> Callback;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With