Matheus28 / ws28

C++17 WebSocket server library (uses libuv)
MIT License
66 stars 10 forks source link

Getting : Headers.h:37:34: error: no match for call to ‘(const main()::<lambda(ws28::HTTPRequest&, ws28::HTTPResponse&)>::<lambda(const char*)>) (const std::basic_string_view<char>&, const std::basic_string_view<char>&)’ #15

Closed meiry closed 1 year ago

meiry commented 1 year ago

Tring to compile your server in ubuntu :

/usr/bin/g++ -fdiagnostics-color=always -Wall -std=c++17 -O0 -g $(find /home/vagrant/ws28 -type f -iregex '.*\.cpp') -I//home/vagrant/libuv/include/ -I/home/vagrant/ws28/src -L/home/vagrant/libuv/build -luv -lssl -lcrypto -o /home/vagrant/ws28/ws.exe

getting :

home/vagrant/ws28/src/Headers.h: In instantiation of ‘void ws28::RequestHeaders::ForEach(const F&) const [with F = main()::<lambda(ws28::HTTPRequest&, ws28::HTTPResponse&)>::<lambda(const char*)>]’:
/home/vagrant/ws28/echo.cpp:44:22:   required from here
/home/vagrant/ws28/src/Headers.h:37:34: error: no match for call to ‘(const main()::<lambda(ws28::HTTPRequest&, ws28::HTTPResponse&)>::<lambda(const char*)>) (const std::basic_string_view<char>&, const std::basic_string_view<char>&)’
   37 |                                 f(p.first, p.second);
      |                                 ~^~~~~~~~~~~~~~~~~~~
/home/vagrant/ws28/echo.cpp:44:37: note: candidate: ‘main()::<lambda(ws28::HTTPRequest&, ws28::HTTPResponse&)>::<lambda(const char*)>’
   44 |                 req.headers.ForEach([&](const char *key/*, const char *value*/){
      |                                     ^
/home/vagrant/ws28/echo.cpp:44:37: note:   candidate expects 1 argument, 2 provided
Matheus28 commented 1 year ago

I think the example server is outdated right now, should be using std::string_view