testBoolCastAdd.cc
Go to the documentation of this file.
1 
8 #include <utl/SafeBoolCast.h>
9 
10 using namespace utl;
11 
12 
13 class C1 : public SafeBoolCast<C1> {
14 public:
15  bool BoolCast() const { return true; }
16 
17  int fI;
18 };
19 
20 
21 class Err1 {
22 public:
23  operator bool() const { return true; }
24 
25  int fI;
26 };
27 
28 
29 int
31 {
32  C1 o1;
33  C1 o2;
34 
35  Err1 oe1;
36  Err1 oe2;
37 
38  // this compiles
39  int i = oe1 + oe2;
40 
41  // this fails
42  const int j = o1 + o2;
43 
44  // to avoid additional warnings
45  i = j;
46 
47  return 0;
48 }
bool BoolCast() const
int main(int argc, char *argv[])
Definition: DBSync.cc:58
int fI

, generated on Tue Sep 26 2023.