Allow epee async call response values to be moved

This allows the caller to also take the response by rvalue reference so
that they can move outsubvalues.  The rvalue is totally fine here (once
the callback is invoked it is never used again) and still binds
perfectly well to const-lvalue accepting callbacks.
This commit is contained in:
Jason Rhinelander 2019-11-01 14:47:03 -03:00
parent cf4d44fb10
commit 29be7f6552

View file

@ -120,23 +120,23 @@ namespace epee
if( code <=0 )
{
LOG_PRINT_L1("Failed to invoke command " << command << " return code " << code);
cb(code, result_struct, context);
cb(code, std::move(result_struct), context);
return false;
}
serialization::portable_storage stg_ret;
if(!stg_ret.load_from_binary(buff))
{
LOG_ERROR("Failed to load_from_binary on command " << command);
cb(LEVIN_ERROR_FORMAT, result_struct, context);
cb(LEVIN_ERROR_FORMAT, std::move(result_struct), context);
return false;
}
if (!result_struct.load(stg_ret))
{
LOG_ERROR("Failed to load result struct on command " << command);
cb(LEVIN_ERROR_FORMAT, result_struct, context);
cb(LEVIN_ERROR_FORMAT, std::move(result_struct), context);
return false;
}
cb(code, result_struct, context);
cb(code, std::move(result_struct), context);
return true;
}, inv_timeout);
if( res <=0 )