Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 25, 2016, 9:33:11 PM (8 years ago)
Author:
muemart
Message:

Constexpr for some util things

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/libraries/util/OrxEnum.h

    r7401 r11096  
    6161    {
    6262        public:
    63             OrxEnum() { }
    64             OrxEnum(int type)            { type_ = type; }
    65             OrxEnum(const T& instance)   { type_ = instance.type_; }
     63            constexpr OrxEnum()                   : type_()                {}
     64            constexpr OrxEnum(int type)           : type_(type)            {}
     65            constexpr OrxEnum(const T& instance)  : type_(instance.type_)  {}
     66            constexpr OrxEnum(const OrxEnum& instance) = delete;
    6667
    67             operator int()               { return type_; }
    68             T& operator =(int type)      { type_ = type; return *this; }
    69             bool operator <(const T& right) const { return (type_ < right.type_); }
    70             bool operator >(const T& right) const { return (type_ > right.type_); }
     68            constexpr operator int() const                  { return type_; }
     69            T& operator =(int type)                         { type_ = type; return *this; }
     70            constexpr bool operator <(const T& right) const { return (type_ < right.type_); }
     71            constexpr bool operator >(const T& right) const { return (type_ > right.type_); }
    7172
    7273        private:
    73             OrxEnum(const OrxEnum& instance);
    7474            int type_;
    7575    };
     
    7777
    7878/// See orxonox::OrxEnum for more info
    79 #define OrxEnumConstructors(enumName)                        \
    80 enumName() { }                                               \
    81 enumName(int type) : OrxEnum<enumName>(type)             { } \
    82 enumName(const enumName& inst) : OrxEnum<enumName>(inst) { } \
     79#define OrxEnumConstructors(enumName)                                  \
     80constexpr enumName() { }                                               \
     81constexpr enumName(int type) : OrxEnum<enumName>(type)             { } \
     82constexpr enumName(const enumName& inst) : OrxEnum<enumName>(inst) { } \
    8383void dummyFunction()
    8484
Note: See TracChangeset for help on using the changeset viewer.