I have got this weird error when compiling my project with Visual Studio 2012:
error C2562: 'std::_Callable_obj<_Ty>::_ApplyX' : 'void' function returning a value C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xrefwrap
When jumping in xrefwrap, the error comes from this line:
_VARIADIC_EXPAND_0X(_APPLYX_CALLOBJ, , , , )
My code compiles fine with GCC on Linux.. Plus the compiler gives me no information on what is causing this error.
What could be the cause of this error? I suspect this piece of code might be the source, but only because I use std::ref there:
_listener.addSocket(clientSock, std::bind(&Client::handleReceive, &client,
_1, std::ref(*this)),
std::bind(&Lounge::handleClientDisconnect, this,
std::cref(client)));
Here are the two signatures of the member functions I am binding:
bool Client::handleReceive(std::shared_ptr<TBSystem::network::sockets::ITcpSocket>& socket,
Lounge& lounge);
void Lounge::handleClientDisconnect(const Client& c);
I do return a value in Client::handleReceive.
And this is the two std::function prototypes I am using when calling addSocket:
typedef std::function<bool (std::shared_ptr<sockets::ITcpSocket>&)> readCallback;
typedef std::function<void ()> disconnectCallback;
Well, turns out in one of my file I added a listener with the wrong prototype (
std::plus)…