mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2026-11-30 19:44:33 -06:00
38 lines
1.2 KiB
Plaintext
38 lines
1.2 KiB
Plaintext
#include <cppx/meta>
|
|
#include <cppx/compiler>
|
|
|
|
using namespace cppx::meta;
|
|
|
|
$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.member_variables())
|
|
if (!f.has_access()) f.make_private();
|
|
for... (auto f : $basic_value.member_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 ordered {
|
|
// stuff here to implement operator < etc
|
|
// NB with constepxr {} blocks and reflection this can be done
|
|
// automatically!
|
|
};
|
|
|
|
$class value : basic_value, ordered { };
|
|
|
|
value Point {
|
|
int x = 0, y = 0;
|
|
Point(int, int);
|
|
void move(int dx, int dy);
|
|
// ... behavior functions ...
|
|
};
|