下面的代碼片段理解錯誤C2664:無法轉換參數1
#include "uWS/uWS.h"
int main()
{
uWS::Hub h;
h.onConnection([&h](uWS::WebSocket<uWS::SERVER> *ws, uWS::HttpRequest req) {
std::cout << "Connected!!!" << std::endl;
});
h.run();
}
產生錯誤
Severity Code Description Project File Line Suppression State Error (active) E0304 no instance of overloaded function "uWS::Hub::onConnection" matches the argument list pid c:\Users\R\src\main.cpp 6 Error C2664 'void uWS::Group<false>::onConnection(std::function<void (uWS::WebSocket<false>,uWS::HttpRequest)>)': cannot convert argument 1 from 'main::<lambda_1afdd040d2f03ded23f0c636dc85475d>' to 'std::function<void (uWS::WebSocket<true>,uWS::HttpRequest)>' pid c:\users\r\src\main.cpp 8
當使用Windows SDK版本10.0內置在Visual Studio 2017年IDE .15063.0, 其中「uWS/uWS.h」包含tiny web sockets definitions
可能是什麼問題?
你好,有同樣的問題,你現在解決這個問題嗎? – HeyJoy
是的,我把uWS :: WebSocket * ws改成了uWS :: WebSocket ws,所有東西都像魅力一樣。顯然,uWS API已經改變。 –
user1934212