In the following code, why is variable t
assigned a correct task when neither of lambdas in the chain return such a type? The lambdas return task<http_response>
, task<json::value>
and none.
The code works when the last lambda returns task and when it returns nothing.
Any pointers to online docs that shed some light on it will be appreciated.
Thanks.
pplx::task<void> t = client.request(methods::GET, L"/api/dummy")
.then([](http_response response)
{
if (response.status_code() == status_codes::OK)
{
response.content_ready().wait();
return response.extract_json(); // return task<json::value>
}
})
.then([](json::value value)
{
if (value.has_field(L"id"))
{
int id = value.at(L"id").as_integer();
}
// t.wait() below works regardless if this
// line is commented out or not.
//return pplx::task<void>({});
});
try
{
t.wait();
}
catch (const std::exception &e)
{
[...]
}