Ref #1506: Add object_downcast_t
Allows the more concise expression `object_downcast_t<xyz>` instead of the old `typename object_downcast<xyz>::type`
This commit is contained in:
parent
14f627c014
commit
9bada13735
4 changed files with 9 additions and 7 deletions
|
|
@ -122,13 +122,13 @@ namespace graphene { namespace db {
|
|||
}
|
||||
|
||||
template<uint8_t SpaceID, uint8_t TypeID>
|
||||
auto find( object_id<SpaceID,TypeID> id )const -> const typename object_downcast<decltype(id)>::type* {
|
||||
return find<typename object_downcast<decltype(id)>::type>(id);
|
||||
auto find( object_id<SpaceID,TypeID> id )const -> const object_downcast_t<decltype(id)>* {
|
||||
return find<object_downcast_t<decltype(id)>>(id);
|
||||
}
|
||||
|
||||
template<uint8_t SpaceID, uint8_t TypeID>
|
||||
auto get( object_id<SpaceID,TypeID> id )const -> const typename object_downcast<decltype(id)>::type& {
|
||||
return get<typename object_downcast<decltype(id)>::type>(id);
|
||||
auto get( object_id<SpaceID,TypeID> id )const -> const object_downcast_t<decltype(id)>& {
|
||||
return get<object_downcast_t<decltype(id)>>(id);
|
||||
}
|
||||
|
||||
template<typename IndexType>
|
||||
|
|
|
|||
|
|
@ -102,6 +102,8 @@ namespace graphene { namespace db {
|
|||
template<> \
|
||||
struct object_downcast<graphene::db::object_id<OBJECT::space_id, OBJECT::type_id>> { using type = OBJECT; }; \
|
||||
} }
|
||||
template<typename ObjectID>
|
||||
using object_downcast_t = typename object_downcast<ObjectID>::type;
|
||||
|
||||
template<uint8_t SpaceID, uint8_t TypeID>
|
||||
struct object_id
|
||||
|
|
|
|||
|
|
@ -659,10 +659,10 @@ public:
|
|||
}
|
||||
|
||||
template<typename ID>
|
||||
typename graphene::db::object_downcast<ID>::type get_object(ID id)const
|
||||
typename graphene::db::object_downcast_t<ID>get_object(ID id)const
|
||||
{
|
||||
auto ob = _remote_db->get_objects({id}).front();
|
||||
return ob.template as<typename graphene::db::object_downcast<ID>::type>( GRAPHENE_MAX_NESTED_OBJECTS );
|
||||
return ob.template as<graphene::db::object_downcast_t<ID>>( GRAPHENE_MAX_NESTED_OBJECTS );
|
||||
}
|
||||
|
||||
void set_operation_fees( signed_transaction& tx, const std::shared_ptr<fee_schedule> s )
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ template<> struct js_name< vote_id_type > { static std::string name(){ retu
|
|||
template<> struct js_name< time_point_sec > { static std::string name(){ return "time_point_sec"; } };
|
||||
|
||||
template<uint8_t S, uint8_t T>
|
||||
struct js_name<graphene::db::object_id<S,T> >
|
||||
struct js_name<graphene::protocol::object_id<S,T> >
|
||||
{
|
||||
static std::string name(){
|
||||
<<<<<<< HEAD
|
||||
|
|
|
|||
Loading…
Reference in a new issue