萌新求助 map 及 pair 的类型模板参数报错
  • 板块灌水区
  • 楼主yuchenren
  • 当前回复7
  • 已保存回复7
  • 发布时间2022/5/10 20:26
  • 上次更新2023/10/28 01:44:32
查看原帖
萌新求助 map 及 pair 的类型模板参数报错
250291
yuchenren楼主2022/5/10 20:26

本人在写项目时编译出来有错误:

错误 C2338 std::function does not accept non-function types as template arguments.

错误 C2440 “<function-style-cast>”: 无法从“initializer list”转换为“std::pair<std::string,std::function<void>>”

我的 map 的定义是这样的:

map <string, function <void>> m;

我的代码片段是:

m.insert(pair <string, function <void>> ("String", Func));

敬请指出蒟蒻写的有误的地方,谢谢!

2022/5/10 20:26
加载中...