]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Comment example.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 3 Sep 1998 12:32:12 +0000 (12:32 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 3 Sep 1998 12:32:12 +0000 (12:32 +0000)
git-svn-id: https://svn.dealii.org/trunk@550 0785d39b-7218-0410-832d-ea1e28bc413d

tests/base/reference.cc

index 03c69251caf4e64ccb51ec156c6f5e09e83e13ec..ae7f092151e92515c4479f943b95f48c53e0786b 100644 (file)
@@ -1,8 +1,9 @@
 
 #include <iostream>
-#include <base/exceptions.h>
 #include <base/subscriptor.h>
 
+
+
 class Test : public Subscriptor
 {
 public:
@@ -16,19 +17,23 @@ public:
   }
 };
 
+
+
 main()
 {
   Test a;
   const Test b;
-  SmartPointer<Test> r=&a;
-  const SmartPointer<Test> s=&a;
-  SmartPointer<Test> t=&b;
-  const SmartPointer<Test> u=&b;
-
-  a.f();
-  b.f();
-  r->f();
-  s->f();
-  t->f();
-  u->f();
+  SmartPointer<Test>       r=&a;
+  SmartPointer<const Test> s=&a;
+  SmartPointer<Test>       t=&b;    // this one should give a warning
+  SmartPointer<const Test> u=&b;
+
+  a.f();            // should print "mutable", since #a# is not const
+  b.f();            // should print "const", since #b# is const
+  r->f();           // should print "mutable", since it points to the non-const #a#
+  s->f();           // should print "const", since it points to the non-const #a#
+                                  // but we made it const
+  t->f();           // should print "mutable", since #b# is const, but
+                                  // we casted the constness away
+  u->f();           // should print "const" since #b# is const
 }

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.