Compilation error C2664: 'void std::_Func_class<_Ret,web::http::http_request>::_Set(std::_Func_base<_Ret,web::http::http_request> *)' : cannot convert argument 1 from '_Myimpl *'

Aug 7 at 12:21 PM
I try to execute the following program.

include <cpprest/http_listener.h>

include <cpprest/json.h>

include <iostream>

include <map>

include <set>

include <string>

using namespace web;
using namespace web::http;
using namespace web::http::experimental::listener;
using namespace std;

define TRACE(msg) wcout << msg

define TRACE_ACTION(a, k, v) wcout << a << L" (" << k << L", " << v << L")\n"

map<utility::string_t, utility::string_t> dictionary;

class ServerAPI{

public:
void handle_request(http_request request, function<void(json::value &, json::value &)> action);
void handle_get(http_request request);
void handle_post(http_request request);
void handle_put(http_request request);
void handle_del(http_request request);
};
/ handlers implementation /
void ServerAPI::handle_get(http_request request)
{
TRACE(L"\nhandle GET\n");

json::value answer;

for (auto const & p : dictionary)
{
    answer[p.first] = json::value(p.second);
}

request.reply(status_codes::OK, answer);
}

/ for PUT, POST, DEL below /
void ServerAPI::handle_request(http_request request,
function<void(json::value &, json::value &)> action)
{
json::value answer;


request
    .extract_json()
    .then([&answer, &action](pplx::task<json::value> task) {
    try
    {
        auto & jvalue = task.get();

        if (!jvalue.is_null())
        {
            action(jvalue, answer);
        }
    }
    catch (http_exception const & e)
    {
        wcout << e.what() << endl;
    }
})
    .wait();

request.reply(status_codes::OK, answer);
}

void ServerAPI::handle_post(http_request request)
{
TRACE("\nhandle POST\n");

handle_request(
    request, [](json::value & jvalue, json::value & answer)
{

    for (auto const & e : jvalue.as_array())
    {
        if (e.is_string())
        {
            auto key = e.as_string();

            auto pos = dictionary.find(key);
            if (pos == dictionary.end())
            {
                answer[key] = json::value(L"<nil>");
            }
            else
            {
                answer[pos->first] = json::value(pos->second);
            }
        }
    }

}

);
}

void ServerAPI::handle_put(http_request request)
{
TRACE("\nhandle PUT\n");

handle_request(
    request,
    [](json::value & jvalue, json::value & answer)
{

    for (auto const & e : jvalue.as_object())
    {
        if (e.second.is_string())
        {
            auto key = e.first;
            auto value = e.second.as_string();

            if (dictionary.find(key) == dictionary.end())
            {
                TRACE_ACTION(L"added", key, value);
                answer[key] = json::value(L"<put>");
            }
            else
            {
                TRACE_ACTION(L"updated", key, value);
                answer[key] = json::value(L"<updated>");
            }

            dictionary[key] = value;
        }
    }

}
);
}

void ServerAPI::handle_del(http_request request)
{
TRACE("\nhandle DEL\n");

handle_request(
    request,
    [](json::value & jvalue, json::value & answer)
{

    set<utility::string_t> keys;
    for (auto const & e : jvalue.as_array())
    {
        if (e.is_string())
        {
            auto key = e.as_string();

            auto pos = dictionary.find(key);
            if (pos == dictionary.end())
            {
                answer[key] = json::value(L"<failed>");
            }
            else
            {
                TRACE_ACTION(L"deleted", pos->first, pos->second);
                answer[key] = json::value(L"<deleted>");
                keys.insert(key);
            }
        }
    }

    for (auto const & key : keys)
        dictionary.erase(key);      
}
);
}

int main()
{
http_listener listener(L"http://localhost/restdemo");

listener.support(methods::GET, &ServerAPI::handle_get);
listener.support(methods::POST,&ServerAPI::handle_post);
listener.support(methods::PUT, &ServerAPI::handle_put);
listener.support(methods::DEL, &ServerAPI::handle_del);

try
{
    listener
        .open()
        .then([&listener]() {TRACE(L"\nstarting to listen\n"); })
        .wait();

    while (true);
}
catch (exception const & e)
{
    wcout << e.what() << endl;
}

getchar();
return 0;
}

and I receive the following error.

c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(506): error C2664: 'void std::_Func_class<_Ret,web::http::http_request>::_Set(std::_Func_base<_Ret,web::http::http_request> *)' : cannot convert argument 1 from '_Myimpl *' to 'std::_Func_base<_Ret,web::http::http_request> *'
1> with
1> [
1> _Ret=void
1> ]
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(442) : see reference to function template instantiation 'void std::_Func_class<_Ret,web::http::http_request>::_Do_alloc<_Myimpl,_Fret(__thiscall ServerAPI::* const &)(web::http::http_request),_Alloc>(_Fty,_Alloc)' being compiled
1> with
1> [
1> _Ret=void
1> , _Fret=void
1> , _Alloc=std::allocator<std::_Func_class<void,web::http::http_request>>
1> , _Fty=void (__thiscall ServerAPI::* const &)(web::http::http_request)
1> ]
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(442) : see reference to function template instantiation 'void std::_Func_class<_Ret,web::http::http_request>::_Do_alloc<_Myimpl,_Fret(__thiscall ServerAPI::* const &)(web::http::http_request),_Alloc>(_Fty,_Alloc)' being compiled
1> with
1> [
1> _Ret=void
1> , _Fret=void
1> , _Alloc=std::allocator<std::_Func_class<void,web::http::http_request>>
1> , _Fty=void (__thiscall ServerAPI::* const &)(web::http::http_request)
1> ]
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(442) : see reference to function template instantiation 'void std::_Func_class<_Ret,web::http::http_request>::_Reset_alloc<_Fret,ServerAPI,web::http::http_request,std::allocator<std::_Func_class<_Ret,web::http::http_request>>>(_Fret (__thiscall ServerAPI::* const )(web::http::http_request),_Alloc)' being compiled
1> with
1> [
1> _Ret=void
1> , _Fret=void
1> , _Alloc=std::allocator<std::_Func_class<void,web::http::http_request>>
1> ]
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(442) : see reference to function template instantiation 'void std::_Func_class<_Ret,web::http::http_request>::_Reset_alloc<_Fret,ServerAPI,web::http::http_request,std::allocator<std::_Func_class<_Ret,web::http::http_request>>>(_Fret (__thiscall ServerAPI::* const )(web::http::http_request),_Alloc)' being compiled
1> with
1> [
1> _Ret=void
1> , _Fret=void
1> , _Alloc=std::allocator<std::_Func_class<void,web::http::http_request>>
1> ]
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(671) : see reference to function template instantiation 'void std::_Func_class<_Ret,web::http::http_request>::_Reset<void,ServerAPI,web::http::http_request>(_Fret (__thiscall ServerAPI::* const )(web::http::http_request))' being compiled
1> with
1> [
1> _Ret=void
1> , _Fret=void
1> ]
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\functional(671) : see reference to function template instantiation 'void std::_Func_class<_Ret,web::http::http_request>::_Reset<void,ServerAPI,web::http::http_request>(_Fret (__thiscall ServerAPI::* const )(web::http::http_request))' being compiled
1> with
1> [
1> _Ret=void
1> , _Fret=void
1> ]
1> c:\users\Jacob\desktop\crossover projects\crossover-serverapi\crossover-serverapi\serverapi-main.cpp(10) : see reference to function template instantiation 'std::function<void (web::http::http_request)>::function<void(__thiscall ServerAPI::* )(web::http::http_request)>(_Fx &&)' being compiled
1> with
1> [
1> _Fx=void (__thiscall ServerAPI::* )(web::http::http_request)
1> ]
1> c:\users\Jacob\desktop\crossover projects\crossover-serverapi\crossover-serverapi\serverapi-main.cpp(10) : see reference to function template instantiation 'std::function<void (web::http::http_request)>::function<void(__thiscall ServerAPI::* )(web::http::http_request)>(_Fx &&)' being compiled
1> with
1> [
1> _Fx=void (__thiscall ServerAPI::* )(web::http::http_request)
1> ]
1> Generating Code...
1>c:\users\Jacob\desktop\crossover projects\crossover-serverapi\crossover-serverapi\serverapi-requesthandler.cpp(78): warning C4717: 'ServerAPI::handle_post' : recursive on all control paths, function will cause runtime stack overflow
1>c:\users\Jacob\desktop\crossover projects\crossover-serverapi\crossover-serverapi\serverapi-requesthandler.cpp(114): warning C4717: 'ServerAPI::handle_put' : recursive on all control paths, function will cause runtime stack overflow
1>



Please help