ZXFoundation™ 26h2
Loading...
Searching...
No Matches
rwonce.cxxm File Reference
module lib.rwonce

C++26 Read-Write Once (Volatile Single-Access) Primitives. More...

import lib.stl;
import zxfoundation.base.types;
Include dependency graph for rwonce.cxxm:

Data Structures

class  lib::rwonce::cell< T >
struct  lib::rwonce::detail::native_uint< usize >
struct  lib::rwonce::detail::native_uint< 1 >
struct  lib::rwonce::detail::native_uint< 16 >
struct  lib::rwonce::detail::native_uint< 2 >
struct  lib::rwonce::detail::native_uint< 4 >
struct  lib::rwonce::detail::native_uint< 8 >
class  lib::rwonce::ref< T >

Concepts

concept  lib::rwonce::detail::has_native_uint
concept  lib::rwonce::Word

Typedefs

template<typename T>
using lib::rwonce::detail::native_uint_t = typename native_uint<sizeof(std::remove_cv_t<T>)>::type

Functions

template<typename T>
constexpr auto lib::rwonce::read_once (const volatile T &x) noexcept -> std::remove_cv_t< T >
 Read a memory location once without compiler caching or reordering.
template<typename T>
 lib::rwonce::ref (T &) -> ref< T >
template<typename T>
requires (!Word<T>)
constexpr auto lib::rwonce::detail::reject_unsupported_type () -> void
template<typename T>
constexpr auto lib::rwonce::write_once (volatile T &x, std::type_identity_t< std::remove_cv_t< T > > val) noexcept -> void
 Write to a memory location once without compiler elision or reordering.

Detailed Description

C++26 Read-Write Once (Volatile Single-Access) Primitives.

SPDX-License-Identifier: Apache-2.0

Function Documentation

◆ read_once()

template<typename T>
auto lib::rwonce::read_once ( const volatile T & x) ->std::remove_cv_t< T >
nodiscardconstexprexportnoexcept

Read a memory location once without compiler caching or reordering.

Parameters
[in]xMemory location to read from
Returns
Stripped non-volatile value copy

◆ write_once()

template<typename T>
auto lib::rwonce::write_once ( volatile T & x,
std::type_identity_t< std::remove_cv_t< T > > val )->void
constexprexportnoexcept

Write to a memory location once without compiler elision or reordering.

Parameters
[out]xDestination memory location
[in]valValue to write