]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
C++11: wrap move semantics operators
authorAmos Jeffries <squid3@treenet.co.nz>
Sat, 14 Mar 2015 04:42:10 +0000 (21:42 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Sat, 14 Mar 2015 04:42:10 +0000 (21:42 -0700)
Allowing older not-quite-C++11 compilers to build for a while longer.

Move is a performance optimization.

src/SBuf.h
src/base/RefCount.h

index 752e9a390d54a6bc67718d48150c1440a9fd39ca..6f39f4bd17a7af1b706d69dbd7e101b161f829a2 100644 (file)
@@ -138,12 +138,14 @@ public:
     /// create an empty (zero-size) SBuf
     SBuf();
     SBuf(const SBuf &S);
+#if __cplusplus >= 201103L
     SBuf(SBuf&& S) : store_(std::move(S.store_)), off_(S.off_), len_(S.len_) {
         ++stats.moves;
-        S.store_=NULL;
+        S.store_=NULL; //RefCount supports NULL, and S is about to be destructed
         S.off_=0;
-        S.len_=0; //RefCount supports NULL
+        S.len_=0;
     }
+#endif
 
     /** Constructor: import c-style string
      *
@@ -180,6 +182,7 @@ public:
      * Current SBuf will share backing store with the assigned one.
      */
     SBuf& operator =(const SBuf & S) {return assign(S);}
+#if __cplusplus >= 201103L
     SBuf& operator =(SBuf &&S) {
         ++stats.moves;
         if (this != &S) {
@@ -192,6 +195,7 @@ public:
         }
         return *this;
     }
+#endif
 
     /** Import a c-string into a SBuf, copying the data.
      *
index 18b6cfb9889836021095ccc703d4a5c31f62b8a0..ec2a98c9d7dfb958a6a121b8e15caed0cfc7486f 100644 (file)
@@ -39,9 +39,11 @@ public:
         reference (p);
     }
 
+#if __cplusplus >= 201103L
     RefCount (RefCount &&p) : p_(std::move(p.p_)) {
         p.p_=NULL;
     }
+#endif
 
     RefCount& operator = (const RefCount& p) {
         // DO NOT CHANGE THE ORDER HERE!!!
@@ -52,6 +54,7 @@ public:
         return *this;
     }
 
+#if __cplusplus >= 201103L
     RefCount& operator = (RefCount&& p) {
         if (this != &p) {
             dereference(p.p_);
@@ -59,6 +62,7 @@ public:
         }
         return *this;
     }
+#endif
 
     bool operator !() const { return !p_; }