vinipsmaker / tufao

An asynchronous web framework for C++ built on top of Qt

Home Page:http://vinipsmaker.github.io/tufao/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

problem using HttpServerRequestRouter with Visual Studio

hmoffatt opened this issue · comments

I'm having trouble using HttpServerRequestRouter with the VS compiler. I can't compile the sessionusage example. It gives the unhelpful error

1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xrefwrap(283): error C2064: term does not evaluate to a function taking 2 arguments

due to the mapping lines (main.cpp:52-54)

{QRegularExpression{"^/set(?:/(\\w*))?$"}, setHandler},
{QRegularExpression{"^/read(?:/(\\w*))?$"}, readHandler},
{QRegularExpression{"^/unset(?:/(\\w*))?$"}, unsetHandler},

This simple code doesn't compile

Tufao::NotFoundHandler notfound;
Tufao::HttpServerRequestRouter::Mapping m;
m.handler = notfound;

Unfortunately if you Google "vs 2013 xrefwrap _Ret std::_Callable_obj" you get heaps of errors like this one. Seems to be a problem with std::function in VS 2013 with no simple workaround.

The compile error is

1>  main.cpp
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xrefwrap(283): error C2064: term does not evaluate to a function taking 2 arguments
1>          C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\functional(228) : see reference to function template instantiation '_Ret std::_Callable_obj<Tufao::NotFoundHandler,false>::_ApplyX<_Rx,Tufao::HttpServerRequest&,Tufao::HttpServerResponse&>(Tufao::HttpServerRequest &,Tufao::HttpServerResponse &)' being compiled
1>          with
1>          [
1>              _Ret=bool
1>  ,            _Rx=bool
1>          ]
1>          C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\functional(228) : see reference to function template instantiation '_Ret std::_Callable_obj<Tufao::NotFoundHandler,false>::_ApplyX<_Rx,Tufao::HttpServerRequest&,Tufao::HttpServerResponse&>(Tufao::HttpServerRequest &,Tufao::HttpServerResponse &)' being compiled
1>          with
1>          [
1>              _Ret=bool
1>  ,            _Rx=bool
1>          ]

Thanks for the report. Unfortunately, I don't have a Windows machine laying around or much time to play with this.

Maybe I should setup AppVeyor for this project just like I did for another project of mine.

However, if std::function doesn't work on Visual Studio 2013, there's no way to fix this issue without breaking API. And I'm not willing to break API. Development versions of Tufão can break the API, but if the API is worse, I'm not willing to accept the proposals. This looks a tough issue.