Changeset 22 for sources/src/sc_uint.h


Ignore:
Timestamp:
Apr 16, 2009, 2:46:01 PM (15 years ago)
Author:
buchmann
Message:

Fix:

  • add missing system header include
  • add a namespace path to atoi

And... code cleanup:

  • bunch of various operators that share the same implementation now are using the same #define.
  • indent and tab/space
File:
1 edited

Legend:

Unmodified
Added
Removed
  • sources/src/sc_uint.h

    r11 r22  
    183183
    184184  // arithmetic
    185   template <typename T>
    186   inline sc_uint& operator <<= (T v)
    187   { vf.valW <<= v; return *this; }
    188   template <typename T>
    189   inline sc_uint& operator >>= (T v)
    190   { vf.valW >>= v; return *this; }
    191   template <typename T>
    192   inline sc_uint& operator += (T v)
    193   { vf.valW += v; return *this; }
    194   template <typename T>
    195   inline sc_uint& operator -= (T v)
    196   { vf.valW -= v; return *this; }
    197   template <typename T>
    198   inline sc_uint& operator *= (T v)
    199   { vf.valW *= v; return *this; }
    200   template <typename T>
    201   inline sc_uint& operator /= (T v)
    202   { vf.valW /= v; return *this; }
    203   template <typename T>
    204   inline sc_uint& operator %= (T v)
    205   { vf.valW %= v; return *this; }
    206   template <typename T>
    207   inline sc_uint& operator &= (T v)
    208   { vf.valW &= v; return *this; }
    209   template <typename T>
    210   inline sc_uint& operator |= (T v)
    211   { vf.valW |= v; return *this; }
    212   template <typename T>
    213   inline sc_uint& operator ^= (T v)
    214   { vf.valW ^= v; return *this; }
     185#define DEFINE_OPERATOR(OPER)        \
     186  template <typename T>              \
     187  inline sc_uint& operator OPER (T v)\
     188  { vf.valW OPER v; return *this; }
     189
     190  DEFINE_OPERATOR(<<=)
     191  DEFINE_OPERATOR(>>=)
     192  DEFINE_OPERATOR(+=)
     193  DEFINE_OPERATOR(-=)
     194  DEFINE_OPERATOR(*=)
     195  DEFINE_OPERATOR(/=)
     196  DEFINE_OPERATOR(%=)
     197  DEFINE_OPERATOR(&=)
     198  DEFINE_OPERATOR(|=)
     199  DEFINE_OPERATOR(^=)
     200#undef DEFINE_OPERATOR
     201
     202#if 0
     203#define DEFINE_OPERATOR(OPER)                                              \
     204  friend bool operator OPER (const data_type& a, const data_type& b);
     205//  { return (a.valW) OPER (b.valW); }
     206
     207  DEFINE_OPERATOR(==)
     208  DEFINE_OPERATOR(!=)
     209  DEFINE_OPERATOR(>=)
     210  DEFINE_OPERATOR(<=)
     211#undef DEFINE_OPERATOR
     212#endif
    215213  inline sc_uint_bit_ref operator [] (int v)
    216214  { return (vf.valW >> v) & 1; }
Note: See TracChangeset for help on using the changeset viewer.