From 29be7f6552d324acae60bcef5a14a90d80fbd801 Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Fri, 1 Nov 2019 14:47:03 -0300 Subject: [PATCH] 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. --- contrib/epee/include/storages/levin_abstract_invoke2.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/contrib/epee/include/storages/levin_abstract_invoke2.h b/contrib/epee/include/storages/levin_abstract_invoke2.h index bfa6ce1fd..4156b490f 100644 --- a/contrib/epee/include/storages/levin_abstract_invoke2.h +++ b/contrib/epee/include/storages/levin_abstract_invoke2.h @@ -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 )