simplify user interface

This commit is contained in:
qicosmos
2019-05-23 18:56:55 +08:00
parent 9449d5576a
commit fef215e7e6
2 changed files with 13 additions and 6 deletions
+11 -2
View File
@@ -30,7 +30,16 @@ namespace rest_rpc {
template<typename T>
inline T get_result(string_view result) {
rpc_service::msgpack_codec codec;
auto err_tp = codec.unpack<std::tuple<int, T>>(result.data(), result.size());
return std::get<1>(err_tp);
auto tp = codec.unpack<std::tuple<int, T>>(result.data(), result.size());
return std::get<1>(tp);
}
template<typename T>
inline T as(string_view result) {
if (has_error(result)) {
throw std::logic_error("rpc error");
}
return get_result<T>(result);
}
}