Using std::function in std::map
11,062
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;
Author by
user3854612
Updated on June 21, 2022Comments
-
user3854612 almost 2 years
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