"ScL Feature"/
ScL Feature 0.0.1
C++20 composable proxy wrapper with pluggable executor strategy
Loading...
Searching...
No Matches
scl::wrapper_guard< Refer > Class Template Reference

RAII guard providing access to the value held by a wrapper or a plain reference. More...

#include <wrapper_guard.h>

Public Member Functions

 wrapper_guard (Refer v)
 Constructs the guard and acquires access to v.
 ~wrapper_guard ()
 Releases the guard acquired at construction.
decltype(auto) value () const noexcept
 Returns the stored value with the same cv- and ref-qualifiers as Refer.

Detailed Description

template<typename Refer>
class scl::wrapper_guard< Refer >

RAII guard providing access to the value held by a wrapper or a plain reference.

For wrapper types calls guard() on the executor at construction and unguard() at destruction (both are no-ops if the executor does not define them). Exposes value() to reach the stored value with the same cv- and ref-qualifiers as the incoming reference.

For non-wrapper types simply holds the reference; no guard/unguard is performed.

Template Parameters
ReferReference type — either wrapper<V,E> cv-ref or a plain value cv-ref.
wrapper_guard<decltype(w) &> g{w};
// g.value() == 42
RAII guard providing access to the value held by a wrapper or a plain reference.
Definition wrapper_guard.h:42
Composable proxy wrapper that delegates to Value through executors.
Definition wrapper.h:72

Constructor & Destructor Documentation

◆ wrapper_guard()

template<typename Refer>
scl::wrapper_guard< Refer >::wrapper_guard ( Refer v)
explicit

Constructs the guard and acquires access to v.

For wrapper types calls executor_type::guard() immediately (if defined). For non-wrapper types simply stores the reference — no side effects.

Parameters
vReference to the wrapper or plain value to guard.

◆ ~wrapper_guard()

template<typename Refer>
scl::wrapper_guard< Refer >::~wrapper_guard ( )

Releases the guard acquired at construction.

For wrapper types calls executor_type::unguard() (if defined). For non-wrapper types is a no-op.

Member Function Documentation

◆ value()

template<typename Refer>
decltype(auto) scl::wrapper_guard< Refer >::value ( ) const
nodiscardnoexcept

Returns the stored value with the same cv- and ref-qualifiers as Refer.

For wrapper types delegates to executor_type::access(). For non-wrapper types returns the held reference unchanged.

Precondition
For wrapper types the guard is held (guaranteed by the constructor).

The documentation for this class was generated from the following file: