Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-12-19 04:04:57

0001 #include "FWCore/Utilities/interface/thread_safety_macros.h"
0002 
0003 class Bar {
0004 public:
0005   void someMethod(int val) { value = val; }
0006 
0007 private:
0008   int value;
0009 };
0010 
0011 // will produce warnings by MutableMemberChecker
0012 class Foo {
0013 public:
0014   void nonConstInConst(int val) const { barMutableMember.someMethod(val); }
0015 
0016   // Shall not produce warning
0017   CMS_THREAD_SAFE void nonConstInConst_safe(int val) const { barMutableMember.someMethod(val); }
0018 
0019   void changeMutableInConst1(double val) const { privateMutable = val; }
0020   void changeMutableInConst2(double val) const { privateMutable += val; }
0021   void changeMutableInConst3(double val) const { privateMutable *= val; }
0022   void changeMutableInConst4(double val) const { privateMutable /= val; }
0023   void changeMutableInConst5(double val) const { privateMutable -= val; }
0024   void changeMutableInConst6(double val) const { privateMutable++; }
0025   void changeMutableInConst7(double val) const { privateMutable--; }
0026 
0027   CMS_THREAD_SAFE void changeMutableInConst_safe(double val) { privateMutable = val * val; };
0028 
0029   mutable int badPublicMutable;
0030 
0031 private:
0032   mutable Bar barMutableMember;
0033   mutable double privateMutable;
0034   int goodMember;
0035 };
0036 
0037 int main() { return 0; }