Browse Source

putil: make UpdateSeq a literal type

rdb 8 years ago
parent
commit
a71a89acc2
2 changed files with 31 additions and 19 deletions
  1. 23 15
      panda/src/putil/updateSeq.I
  2. 8 4
      panda/src/putil/updateSeq.h

+ 23 - 15
panda/src/putil/updateSeq.I

@@ -11,48 +11,56 @@
  * @date 1999-09-30
  * @date 1999-09-30
  */
  */
 
 
+/**
+ * Creates an UpdateSeq in the given state.
+ */
+CONSTEXPR UpdateSeq::
+UpdateSeq(unsigned int seq) : _seq(seq) {
+}
+
 /**
 /**
  * Creates an UpdateSeq in the 'initial' state.
  * Creates an UpdateSeq in the 'initial' state.
  */
  */
-INLINE UpdateSeq::
-UpdateSeq() {
-  _seq = (unsigned int)SC_initial;
+CONSTEXPR UpdateSeq::
+UpdateSeq() : _seq((unsigned int)SC_initial) {
 }
 }
 
 
 /**
 /**
  * Returns an UpdateSeq in the 'initial' state.
  * Returns an UpdateSeq in the 'initial' state.
  */
  */
-INLINE UpdateSeq UpdateSeq::
+CONSTEXPR UpdateSeq UpdateSeq::
 initial() {
 initial() {
-  return UpdateSeq();
+  return UpdateSeq((unsigned int)SC_initial);
 }
 }
 
 
 /**
 /**
  * Returns an UpdateSeq in the 'old' state.
  * Returns an UpdateSeq in the 'old' state.
  */
  */
-INLINE UpdateSeq UpdateSeq::
+CONSTEXPR UpdateSeq UpdateSeq::
 old() {
 old() {
-  UpdateSeq result;
-  result._seq = (unsigned int)SC_old;
-  return result;
+  return UpdateSeq((unsigned int)SC_old);
 }
 }
 
 
 /**
 /**
  * Returns an UpdateSeq in the 'fresh' state.
  * Returns an UpdateSeq in the 'fresh' state.
  */
  */
-INLINE UpdateSeq UpdateSeq::
+CONSTEXPR UpdateSeq UpdateSeq::
 fresh() {
 fresh() {
-  UpdateSeq result;
-  result._seq = (unsigned int)SC_fresh;
-  return result;
+  return UpdateSeq((unsigned int)SC_fresh);
 }
 }
 
 
 /**
 /**
  *
  *
  */
  */
 INLINE UpdateSeq::
 INLINE UpdateSeq::
-UpdateSeq(const UpdateSeq &copy) {
-  _seq = AtomicAdjust::get(copy._seq);
+UpdateSeq(const UpdateSeq &copy) : _seq(AtomicAdjust::get(copy._seq)) {
+}
+
+/**
+ *
+ */
+CONSTEXPR UpdateSeq::
+UpdateSeq(const UpdateSeq &&from) NOEXCEPT : _seq(from._seq) {
 }
 }
 
 
 /**
 /**

+ 8 - 4
panda/src/putil/updateSeq.h

@@ -35,13 +35,17 @@
  * sequences are numeric and are monotonically increasing.
  * sequences are numeric and are monotonically increasing.
  */
  */
 class EXPCL_PANDA_PUTIL UpdateSeq {
 class EXPCL_PANDA_PUTIL UpdateSeq {
+private:
+  CONSTEXPR UpdateSeq(unsigned int seq);
+
 PUBLISHED:
 PUBLISHED:
-  INLINE UpdateSeq();
-  INLINE static UpdateSeq initial();
-  INLINE static UpdateSeq old();
-  INLINE static UpdateSeq fresh();
+  CONSTEXPR UpdateSeq();
+  CONSTEXPR static UpdateSeq initial();
+  CONSTEXPR static UpdateSeq old();
+  CONSTEXPR static UpdateSeq fresh();
 
 
   INLINE UpdateSeq(const UpdateSeq &copy);
   INLINE UpdateSeq(const UpdateSeq &copy);
+  CONSTEXPR UpdateSeq(const UpdateSeq &&from) NOEXCEPT;
   INLINE UpdateSeq &operator = (const UpdateSeq &copy);
   INLINE UpdateSeq &operator = (const UpdateSeq &copy);
 
 
   INLINE void clear();
   INLINE void clear();