cpprestsdk icon indicating copy to clipboard operation
cpprestsdk copied to clipboard

Different behavior on different platforms

Open mortificador opened this issue 8 years ago • 1 comments

Hi, I've noticed that in Linux this code is perfectly valid and work as expected:

web::http::client::http_client client(web::uri(U("http://www.bing.com")));
 web::uri_builder builder;
 std::promise<int> p;
 auto val = client.request( builder.to_string() )
   .then( [p = std::move(p) ] ( pplx::task<web::http::http_response> task_response ) mutable
 {
   auto response = task_response.get();
   p.set_value( 3 );
   return 4;
 } );

However this code won't compile on Windows, because on this line (ppltasks.h, line 3141): return _ThenImpl<_ReturnType>(typename details::_ContinuationTypeTraits<_Function, _ReturnType>::_StdFuncT(_Func), _Options);The callback is copied, and a std::promise has the copy ctor deleted. I've tried different things, like defining _PPLTASKS_NO_STDFUNC, but none of them have solved the problem.

Is this a bug, is there something that I can do to get the same behavior on Linux and Windows?

Thank you very much

mortificador avatar Jul 01 '17 18:07 mortificador

hi, same problem here, have you solved it?

xi-loong avatar Sep 15 '21 06:09 xi-loong