aboutsummaryrefslogtreecommitdiff
path: root/examples/cppx/default.cpp
diff options
context:
space:
mode:
authorMatt Godbolt <matt@godbolt.org>2020-09-17 21:59:34 -0500
committerMatt Godbolt <matt@godbolt.org>2020-09-17 21:59:34 -0500
commit33bb9965cdb38134c0615874f22ee623813a2fc2 (patch)
treeaf9f26785385dfa4bc8d1f35960487c2a99a85a8 /examples/cppx/default.cpp
parent8c06f7ebfa3233bcdc7460f3c956a12f6575af11 (diff)
downloadcompiler-explorer-33bb9965cdb38134c0615874f22ee623813a2fc2.tar.gz
compiler-explorer-33bb9965cdb38134c0615874f22ee623813a2fc2.zip
Partially address #2201
Diffstat (limited to 'examples/cppx/default.cpp')
-rw-r--r--examples/cppx/default.cpp49
1 files changed, 2 insertions, 47 deletions
diff --git a/examples/cppx/default.cpp b/examples/cppx/default.cpp
index 503cffe41..3e1d904d2 100644
--- a/examples/cppx/default.cpp
+++ b/examples/cppx/default.cpp
@@ -1,47 +1,2 @@
-//====================================================================
-// Library code: implementing the metaclass (once)
-
-$class basic_value {
- basic_value() = default;
- basic_value(const basic_value& that) = default;
- basic_value(basic_value&& that) = default;
- basic_value& operator=(const basic_value& that) = default;
- basic_value& operator=(basic_value&& that) = default;
-
- constexpr {
- for... (auto f : $basic_value.variables())
- if (!f.has_access()) f.make_private();
- for... (auto f : $basic_value.functions()) {
- if (!f.has_access()) f.make_public();
- compiler.require(!f.is_protected(), "a value type may not have a protected function");
- compiler.require(!f.is_virtual(), "a value type may not have a virtual function");
- compiler.require(!f.is_destructor() || f.is_public(), "a value destructor must be public");
- }
- }
-};
-
-$class value : basic_value { };
-
-
-//====================================================================
-// User code: using the metaclass to write a type (many times)
-
-value Point {
- int x = 0, y = 0;
- Point(int xx, int yy) : x{xx}, y{yy} { }
-};
-
-Point get_some_point() { return {1,1}; }
-
-int main() {
-
- Point p1(50,100), p2;
- p2 = get_some_point();
- p2.x = 42;
-
-}
-
-// Compiler Explorer note: Click the "triangle ! icon" to see the output:
-constexpr {
- compiler.debug($Point);
-}
+// Pick an appropriate example from the Load/Save
+// icon above.