C++ VS 2013 中的 11 lambda 回调无法编译
C++ 11 lambda callback in VS 2013 won't compile
我不明白为什么下面的代码不能在VS2013中编译。编译器只是抱怨如下,我不知道如何修复它:
e: \work\justtest\coconsole\coconsole.cpp(37):错误C2664:'booldfsFolder(const wchar_t*,const wchar_t*,std::function&)':无法从转换参数3'main::'到'std::函数&'
bool dfsFolder(__in const wchar_t* folderPath, __in const wchar_t* ext, const std::function<bool(const std::wstring& wsFilePath)>& pFunc)
{
}
int main()
{
auto path = LR"(F:TODOWNLOAD)";
auto lambda = [&](const std::wstring& wsFilePath) mutable -> bool
{
wcout << wsFilePath << endl;
return true;
};
dfsFolder(path, L"*.jpg", lambda);
}
错误消息似乎与代码不匹配:最后一个参数是std::function<...> const&
,而不是错误中所述的std::function<...>&
。您的实际代码是否将std::function<...>&
参数声明为const
?
相关文章:
- 架构决策:返回std::future还是提供回调
- 正在为Xtensa simcall函数编写回调函数
- 如何在C++中使用非静态成员函数作为回调函数
- FLTK:按下哪个按钮 - 将数字传递给按钮的回调 (lambda)
- 在简单示例中,Python3 + ctypes 回调会导致内存泄漏
- 用于在回调中调用解析器的设计模式
- 如何使用C++对象的成员函数作为 C 样式回调?
- Java从C++回调到C++回调
- 如何将成员函数作为回调参数传递给需要"typedef-ed"自由函数指针的函数?
- 从不同的 cpp 调用回调函数会导致bad_function_call
- pcap_handler回调仅在使用 NPCAP v0.9991 时包含空数据包
- Steam 回调在 Linux / GCC 编译期间触发警告
- 更新 Visual Studio 2017,现在出现编译错误 C7510:"回调":使用依赖模板名称必须以 'template' 为前缀
- C 11 std :: bind and auto的编译错误,用于回调函数参数
- C++ VS 2013 中的 11 lambda 回调无法编译
- 回调中的函数:编译错误
- c++回调——编译时虚拟函数的替代品
- 我如何用在这个回调中具有编译时类型检查的东西替换void指针?
- 在openGL中注册回调时出现编译错误
- 指向回调函数的指针.编译错误