[ Web Proxy ]
URL:
Viewing: https://en.cppreference.com/cpp/utility/observable_checkpoint [Back]  [Original]

std::observable_checkpoint - cppreference.com
cppreference.com
Namespaces
Variants

std::observable_checkpoint

From cppreference.com
 
 
Utilities library
General utilities
Relational operators (deprecated in C++20)
Integer comparison functions
(C++20)(C++20)(C++20)    
(C++20)
Swap and type operations
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
Undefined behavior utilities
Common vocabulary types
(C++11)
(C++17)
(C++17)
(C++17)
(C++11)
(C++17)
(C++23)



 
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

#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

marks unreachable point of execution
(function) [edit]

Web Proxy Viewer  |  New URL  |  Original Page