Hello,
I tried to compile the example in How to: Work with Asynchronous Streams on VS2010 and I got the following errors:
I tried to compile the example in How to: Work with Asynchronous Streams on VS2010 and I got the following errors:
pplxtasks.h(385): error C2338: incorrect parameter type for the callable object in 'then'; consider _ExpectedParameterType or task<_ExpectedParameterType> (see below)
pplxtasks.h(400) : see reference to class template instantiation 'pplx::details::_FunctionTypeTraits<_Function,_ExpectedParameterType>' being compiled
with
[
_Function=int,
_ExpectedParameterType=size_t
]
example.cpp(66) : see reference to class template instantiation 'pplx::details::_ContinuationTypeTraits<_Function,_ReturnType>' being compiled
with
[
_Function=int,
_ReturnType=size_t
]
example.cpp(58): error C3499: a lambda that has been specified to have a void return type cannot return a value
example.cpp(66): error C3499: a lambda that has been specified to have a void return type cannot return a value
All errors involve the lambda expressions in the HTTPStreamingAsync() function. The last 2 can be fixed by adding the lambda return type, like this:
return client.request(methods::GET).then([](http_response response) -> pplx::task<void>
{
...
});
However, I have not been able to find a solution for the first problem. It looks like the compiler can't resolve the type of the lambda expression passed as a continuation for the task returned from read():
return bodyStream.read(inStringBuffer, 15).then([inStringBuffer](size_t bytesRead)
{
const std::string &text = inStringBuffer.collection();
// For demonstration, convert the response text to a wide-character string.
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>, wchar_t> utf16conv;
std::wostringstream ss;
ss << utf16conv.from_bytes(text.c_str()) << std::endl;
std::wcout << ss.str();
});
Is there any workaround or fix?