[Rivet-svn] rivet: Explicit bool conversion in rivet_shared_ptr, implement u...

Rivet Mercurial rivet at projects.hepforge.org
Wed Feb 7 13:15:02 GMT 2018


details:   https://rivet.hepforge.org/hg/rivet/rev/bc6bb7137999
branches:  multiweight
changeset: 6238:bc6bb7137999
user:      David Grellscheid <david.grellscheid at durham.ac.uk>
date:      Wed Feb 07 13:08:52 2018 +0000
description:
Explicit bool conversion in rivet_shared_ptr, implement usual ptr comparison operators.

diffs (truncated from 86 to 50 lines):

--- a/include/Rivet/Tools/RivetYODA.hh	Wed Jan 31 11:15:23 2018 +0000
+++ b/include/Rivet/Tools/RivetYODA.hh	Wed Feb 07 13:08:52 2018 +0000
@@ -47,6 +47,7 @@
             virtual void setActiveWeightIdx(unsigned int iWeight) = 0;
 
             bool operator ==(const AnalysisObjectWrapper& p) { return (this == &p); }
+            bool operator !=(const AnalysisObjectWrapper& p) { return (this != &p); }
 
         protected:
             /// @todo do we need this?
@@ -67,7 +68,7 @@
             }
 
             bool operator!() const { return !_persistent; }
-            operator bool() const { return bool(_persistent); }
+            explicit operator bool() const { return bool(_persistent); }
 
             YODA::Scatter1D* operator->() { return _persistent.get(); }
 
@@ -91,7 +92,7 @@
             Scatter2DPtr() : _persistent() { }
 
             bool operator!() { return !_persistent; }
-            operator bool() { return bool(_persistent); }
+            explicit operator bool() { return bool(_persistent); }
 
             YODA::Scatter2D* operator->() { return _persistent.get(); }
 
@@ -115,7 +116,7 @@
             Scatter3DPtr() : _persistent() { }
 
             bool operator!() { return !_persistent; }
-            operator bool() { return bool(_persistent); }
+            explicit operator bool() { return bool(_persistent); }
 
             YODA::Scatter3D* operator->() { return _persistent.get(); }
 
@@ -296,7 +297,7 @@
         /* @todo this probably need to loop over all? */
         bool operator!() const { return !_active; } // Don't use active() here, assert will catch
 
-        operator bool() const { return static_cast<bool>(_active); } // Don't use active() here, assert will catch
+        explicit operator bool() const { return static_cast<bool>(_active); } // Don't use active() here, assert will catch
 
         T * operator->() { return active().get(); }
 
@@ -419,13 +420,38 @@
   const typename T::Inner & operator*() const { return **_p; }
 
   bool operator!() const { return !_p || !(*_p);   }


More information about the Rivet-svn mailing list