std::observable_checkpoint
From cppreference.com
| Defined in header <utility>
|
||
void observable_checkpoint() noexcept;
|
(since C++26) | |
Establishes an observable checkpoint.
Notes
| Feature-test macro | Value | Std | Feature |
|---|---|---|---|
__cpp_lib_observable_checkpoint |
202506L |
(C++26) | std::observable_checkpoint
|
Example
Run this code
#include <iostream>
#include <utility>
struct Reactor
{
/* ... */
void turn_off() {}
};
void turn_off(Reactor* reactor)
{
std::clog << "[Diagnostic] About to turn off the reactor...\n";
std::observable_checkpoint(); // Everything observable before this line must happen
reactor->turn_off(); // UB, if reactor is null
}
int main()
{
turn_off(nullptr);
}
Output:
[Diagnostic] About to turn off the reactor...
See also
(C++23) |
marks unreachable point of execution (function) |