Bug 1122160 Add operator+=() and operator-=() to DebugOnly r=froydnj
authorBen Kelly <ben@wanderview.com>
Fri, 16 Jan 2015 09:59:32 -0500
changeset 251379 7a80f8e49992a4bba5e1a6d769648b70b6cd840f
parent 251378 56824531bfec29b5f4e9dcb4cd11d1eee8b27cba
child 251380 bcb08a5d407fbb4ddb1b4da8eef5dc0f4d97c88e
push id4610
push userjlund@mozilla.com
push dateMon, 30 Mar 2015 18:32:55 +0000
treeherdermozilla-beta@4df54044d9ef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1122160
milestone38.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1122160 Add operator+=() and operator-=() to DebugOnly r=froydnj
mfbt/DebugOnly.h
--- a/mfbt/DebugOnly.h
+++ b/mfbt/DebugOnly.h
@@ -46,31 +46,37 @@ public:
   DebugOnly& operator=(const T& aRhs) {
     value = aRhs;
     return *this;
   }
 
   void operator++(int) { value++; }
   void operator--(int) { value--; }
 
+  // Do not define operator+=() or operator-=() here.  These will coerce via
+  // the implicit cast and built-in ooperators.  Defining explicit methods here
+  // will create ambiguity the compiler can't deal with.
+
   T* operator&() { return &value; }
 
   operator T&() { return value; }
   operator const T&() const { return value; }
 
   T& operator->() { return value; }
   const T& operator->() const { return value; }
 
 #else
   DebugOnly() { }
   MOZ_IMPLICIT DebugOnly(const T&) { }
   DebugOnly(const DebugOnly&) { }
   DebugOnly& operator=(const T&) { return *this; }
   void operator++(int) { }
   void operator--(int) { }
+  DebugOnly& operator+=(const T&) { return *this; }
+  DebugOnly& operator-=(const T&) { return *this; }
 #endif
 
   /*
    * DebugOnly must always have a destructor or else it will
    * generate "unused variable" warnings, exactly what it's intended
    * to avoid!
    */
   ~DebugOnly() {}