Commits

George Russell  committed f924dbf

A link to executable

  • Participants
  • Parent commits 2a1ebff

Comments (0)

Files changed (1)

-== Welcome ==
-
-ConstCPP is C++ with the const modifier on, all of the time. Except when you 
-use mutable instead.
-
-This is a hacked together compiler patching clang/LLVM 2.9 and is in no way
-actually tested, rigourously designed, or necessarily useful or usable.
-It is also incompatible with ~99% of existing C++ code, including standard headers...
-
-Inspired by a tweet from @tim_angus 
-{{{
-    "I've often wondered if const-ness should be the 
-    default and removed with a mutable keyword instead"
-}}}
-
-=== Examples of ConstCPP ===
-
-Here's an example of some ConstCPP code:
-
-Local or global scalar variables work as before, except they are constant by default.
-
-{{{
-#!c++
-
-void f() {
-    int a = 0;         // <- const int a = 0;
-    mutable int b = 1; // <-       int b = 1;
-    b = 2;
-}
-
-}}}
-
-Aggregate types work a little differently. To act as before, all fields must be
-declared mutable, and the variable declarations of struct type must also be declared
-mutable.
-
-{{{
-#!c++
-
+== Welcome ==
+
+ConstCPP is C++ with the const modifier on, all of the time. Except when you 
+use mutable instead.
+
+This is a hacked together compiler patching clang/LLVM 2.9 and is in no way
+actually tested, rigourously designed, or necessarily useful or usable.
+It is also incompatible with ~99% of existing C++ code, including standard headers...
+
+Inspired by a tweet from @tim_angus 
+{{{
+    "I've often wondered if const-ness should be the 
+    default and removed with a mutable keyword instead"
+}}}
+
+=== Examples of ConstCPP ===
+
+Here's an example of some ConstCPP code:
+
+Local or global scalar variables work as before, except they are constant by default.
+
+{{{
+#!c++
+
+void f() {
+    int a = 0;         // <- const int a = 0;
+    mutable int b = 1; // <-       int b = 1;
+    b = 2;
+}
+
+}}}
+
+Aggregate types work a little differently. To act as before, all fields must be
+declared mutable, and the variable declarations of struct type must also be declared
+mutable.
+
+{{{
+#!c++
+
 struct Normal {
     mutable int a, b; 
     
     n.b = 1;
     n2  = n; 
     return n2.a + n2.b;
-}
-
-}}}
-
-Omitting a mutable declarator means the struct contains a non-static const member,
-which has implications such that we must initialise it explicitly in a constructor
-initialisation list, and we cannot (without subverting the type system by casting away
-const-ness in an overload of operator= ) assign one instance of the struct to another 
-variable of the same type.
-
-{{{
-#!c++
-
+}
+
+}}}
+
+Omitting a mutable declarator means the struct contains a non-static const member,
+which has implications such that we must initialise it explicitly in a constructor
+initialisation list, and we cannot (without subverting the type system by casting away
+const-ness in an overload of operator= ) assign one instance of the struct to another 
+variable of the same type.
+
+{{{
+#!c++
+
 struct PartMutable {
     int a;
     mutable int b;
     mutable PartMutable n;
     n.b = 1;
     return n.a + n.b;
-}
-
-}}}
-
-Methods can be overloaded on the basis of mutable and non-mutable.
-The default is for a method to be const; the mutable keyword is
-supported to remove const-ness. The const keyword is still supported,
-but code with both no-qualifier and a const-qualifier will fail to 
-compile, as the two are now equivalent. The mutable keyword needs
-added.
-
-{{{
-#!c++
-
+}
+
+}}}
+
+Methods can be overloaded on the basis of mutable and non-mutable.
+The default is for a method to be const; the mutable keyword is
+supported to remove const-ness. The const keyword is still supported,
+but code with both no-qualifier and a const-qualifier will fail to 
+compile, as the two are now equivalent. The mutable keyword needs
+added.
+
+{{{
+#!c++
+
 extern "C" {
     int printf( char *, ...);
 }
-
+
 struct NotMutable {
     int a, b;
     NotMutable() : a(0), b(0) {}
 
 Overloads can also be done on the basis of mutable vs non-mutable.
 
-{{{
+{{{
 #!c++
 
 int f5(int* p) { return *p; }
 
 {{{
    clang.exe -ConstByDefault test.cpp
-}}}
+}}}
+
+A Windows executable can be downloaded [[https://bitbucket.org/grrussel/constcpp/downloads/clang.7z|as a 7zip archive]]