From efa47d298fe218b6867197cb6fa9db42a18ba66b Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Sun, 14 Apr 2019 15:41:42 -0500 Subject: [PATCH] Ref #1506: Add object_downcast_t Allows the more concise expression `object_downcast_t` instead of the old `typename object_downcast::type` --- libraries/db/include/graphene/db/object_database.hpp | 8 ++++---- libraries/db/include/graphene/db/object_id.hpp | 2 ++ libraries/wallet/wallet.cpp | 4 ++-- programs/js_operation_serializer/main.cpp | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/libraries/db/include/graphene/db/object_database.hpp b/libraries/db/include/graphene/db/object_database.hpp index 73807eebb8..c7825572fb 100644 --- a/libraries/db/include/graphene/db/object_database.hpp +++ b/libraries/db/include/graphene/db/object_database.hpp @@ -122,13 +122,13 @@ namespace graphene { namespace db { } template - auto find( object_id id )const -> const typename object_downcast::type* { - return find::type>(id); + auto find( object_id id )const -> const object_downcast_t* { + return find>(id); } template - auto get( object_id id )const -> const typename object_downcast::type& { - return get::type>(id); + auto get( object_id id )const -> const object_downcast_t& { + return get>(id); } template diff --git a/libraries/db/include/graphene/db/object_id.hpp b/libraries/db/include/graphene/db/object_id.hpp index 68de0bd2ac..9bdfe550ea 100644 --- a/libraries/db/include/graphene/db/object_id.hpp +++ b/libraries/db/include/graphene/db/object_id.hpp @@ -100,6 +100,8 @@ namespace graphene { namespace db { template<> \ struct object_downcast> { using type = OBJECT; }; \ } } + template + using object_downcast_t = typename object_downcast::type; template struct object_id diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index e21f43de48..4febf34b2b 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -533,10 +533,10 @@ class wallet_api_impl } template - typename graphene::db::object_downcast::type get_object(ID id)const + typename graphene::db::object_downcast_tget_object(ID id)const { auto ob = _remote_db->get_objects({id}).front(); - return ob.template as::type>( GRAPHENE_MAX_NESTED_OBJECTS ); + return ob.template as>( GRAPHENE_MAX_NESTED_OBJECTS ); } void set_operation_fees( signed_transaction& tx, const fee_schedule& s ) diff --git a/programs/js_operation_serializer/main.cpp b/programs/js_operation_serializer/main.cpp index 833e82f8ad..4466ce2efa 100644 --- a/programs/js_operation_serializer/main.cpp +++ b/programs/js_operation_serializer/main.cpp @@ -130,7 +130,7 @@ struct js_name > static std::string name(){ using namespace graphene::db; return "protocol_id_type \"" + - remove_namespace(fc::get_typename>::type>::name()) + + remove_namespace(fc::get_typename>>::name()) + "\""; }; };