Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 8, 2015, 9:10:30 PM (8 years ago)
Author:
landauf
Message:

in C++11 it's now possible to define 'typedefs' for templates (called 'alias template')

Location:
code/branches/cpp11_v2/src/libraries/core/command
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11_v2/src/libraries/core/command/ExecutorPtr.h

    r10769 r10781  
    5353namespace orxonox
    5454{
    55     /// ExecutorPtr is just a typedef of SharedPtr
    56     typedef SharedPtr<Executor> ExecutorPtr;
    57 
    58     /// ExecutorStaticPtr is just a typedef of SharedChildPtr
    59     typedef SharedChildPtr<ExecutorStatic, ExecutorPtr> ExecutorStaticPtr;
    60 
    61     /// It's not possible to use a typedef for ExecutorMemberPtr<T>, so we have to create a child-class instead. It inherits all functions from SharedChildPtr, but needs to (re-)implement some constructors.
     55    using ExecutorPtr = SharedPtr<Executor>;
     56    using ExecutorStaticPtr = SharedChildPtr<ExecutorStatic, ExecutorPtr>;
    6257    template <class T>
    63     class ExecutorMemberPtr : public SharedChildPtr<ExecutorMember<T>, ExecutorPtr>
    64     {
    65         public:
    66             inline ExecutorMemberPtr() : SharedChildPtr<ExecutorMember<T>, ExecutorPtr>() {}
    67             inline ExecutorMemberPtr(ExecutorMember<T>* pointer) : SharedChildPtr<ExecutorMember<T>, ExecutorPtr>(pointer) {}
    68             inline ExecutorMemberPtr(const SharedPtr<ExecutorMember<T>>& other) : SharedChildPtr<ExecutorMember<T>, ExecutorPtr>(other) {}
    69     };
     58    using ExecutorMemberPtr = SharedChildPtr<ExecutorMember<T>, ExecutorPtr>;
    7059}
    7160
  • code/branches/cpp11_v2/src/libraries/core/command/FunctorPtr.h

    r10769 r10781  
    5555namespace orxonox
    5656{
    57     /// FunctorPtr is just a typedef of SharedPtr
    58     typedef SharedPtr<Functor> FunctorPtr;
    59 
    60     /// It's not possible to use a typedef for FunctorMemberPtr<T>, so we have to create a child-class instead. It inherits all functions from SharedChildPtr, but needs to (re-)implement some constructors.
     57    using FunctorPtr = SharedPtr<Functor>;
    6158    template <class T>
    62     class FunctorMemberPtr : public SharedChildPtr<FunctorMember<T>, FunctorPtr>
    63     {
    64         public:
    65             inline FunctorMemberPtr() : SharedChildPtr<FunctorMember<T>, FunctorPtr>() {}
    66             inline FunctorMemberPtr(FunctorMember<T>* pointer) : SharedChildPtr<FunctorMember<T>, FunctorPtr>(pointer) {}
    67             inline FunctorMemberPtr(const SharedPtr<FunctorMember<T>>& other) : SharedChildPtr<FunctorMember<T>, FunctorPtr>(other) {}
    68     };
    69 
    70     /// FunctorStaticPtr is just FunctorMemberPtr with @a T = void
    71     typedef FunctorMemberPtr<void> FunctorStaticPtr;
    72 
    73     /// It's not possible to use a typedef for FunctorPointerPtr<T>, so we have to create a child-class instead. It inherits all functions from SharedChildPtr, but needs to (re-)implement some constructors.
     59    using FunctorMemberPtr = SharedChildPtr<FunctorMember<T>, FunctorPtr>;
     60    using FunctorStaticPtr = FunctorMemberPtr<void>;
    7461    template <class F, class T>
    75     class FunctorPointerPtr : public SharedChildPtr<FunctorPointer<F, T>, FunctorMemberPtr<T>>
    76     {
    77         public:
    78             inline FunctorPointerPtr() : SharedChildPtr<FunctorPointer<F, T>, FunctorMemberPtr<T>>() {}
    79             inline FunctorPointerPtr(FunctorPointer<F, T>* pointer) : SharedChildPtr<FunctorPointer<F, T>, FunctorMemberPtr<T>>(pointer) {}
    80             inline FunctorPointerPtr(const SharedPtr<FunctorPointer<F, T>>& other) : SharedChildPtr<FunctorPointer<F, T>, FunctorMemberPtr<T>>(other) {}
    81     };
     62    using FunctorPointerPtr = SharedChildPtr<FunctorPointer<F, T>, FunctorMemberPtr<T>>;
    8263}
    8364
Note: See TracChangeset for help on using the changeset viewer.