Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions CPP20.md
Original file line number Diff line number Diff line change
Expand Up @@ -490,10 +490,10 @@ char8_t utf8_str[] = u8"\u0123";
The `constinit` specifier requires that a variable must be initialized at compile-time.
```c++
const char* g() { return "dynamic initialization"; }
constexpr const char* f(bool p) { return p ? "constant initializer" : g(); }
constexpr const char* f() { return "constant initializer"; }

constinit const char* c = f(true); // OK
constinit const char* d = g(false); // ERROR: `g` is not constexpr, so `d` cannot be evaluated at compile-time.
constinit const char* c = f(); // OK
constinit const char* d = g(); // ERROR: `g` is not constexpr, so `d` cannot be evaluated at compile-time.
```

### \_\_VA\_OPT\_\_
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -594,10 +594,10 @@ char8_t utf8_str[] = u8"\u0123";
The `constinit` specifier requires that a variable must be initialized at compile-time.
```c++
const char* g() { return "dynamic initialization"; }
constexpr const char* f(bool p) { return p ? "constant initializer" : g(); }
constexpr const char* f() { return "constant initializer"; }

constinit const char* c = f(true); // OK
constinit const char* d = g(false); // ERROR: `g` is not constexpr, so `d` cannot be evaluated at compile-time.
constinit const char* c = f(); // OK
constinit const char* d = g(); // ERROR: `g` is not constexpr, so `d` cannot be evaluated at compile-time.
```

### \_\_VA\_OPT\_\_
Expand Down