Skip to content

Update metafunctions.md #1015

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions docs/cpp2/metafunctions.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ point2d: @value type = {

## <a id="generating-source"></a>Generating source code at compile time

A metafunction applied to a definition using `@` gets to participate in interpreting the meaning of the definition by inspecting and manipulating the definition's parse tree. For example
A metafunction applied to a definition using `@` gets to participate in interpreting the meaning of the definition by inspecting and manipulating the definition's parse tree. For example:

``` cpp title="shape.cpp2: Using @interface @print" hl_lines="1"
shape: @interface @print type = {
Expand Down Expand Up @@ -128,6 +128,17 @@ A `basic_value` type is a regular type: [`copyable`](#copyable), default constru

A `value` (or `weakly_ordered_value` or `partially_ordered_value`) is a `basic_value` that is also [`ordered`](#ordered) (or `weakly_ordered` or `partially_ordered`, respectively).

```mermaid
graph TD;
value---->basic_value;
weakly_ordered_value---->basic_value;
partially_ordered_value---->basic_value;
basic_value-->copyable;
value-->ordered;
partially_ordered_value-->partially_ordered;
weakly_ordered_value-->weakly_ordered;
```

These metafunctions will emit a compile-time error if:

- any function is protected or virtual
Expand All @@ -142,6 +153,7 @@ These metafunctions will emit a compile-time error if:
>
> — P0707R4, section 3


#### `struct`

A `struct` is a type with only public bases, objects, and functions, with no virtual functions, and with no user-defined constructors (i.e., no invariants) or assignment or destructors.
Expand Down Expand Up @@ -187,7 +199,7 @@ Cpp2 has no `interface` feature hardwired into the language, as C# and Java do.

- the type has a copy or move function (the diagnostic message will suggest a virtual `clone` function instead)

- any function has body
- any function has a body

- any function is nonpublic

Expand Down