|
ScL Feature 0.0.1
C++20 composable proxy wrapper with pluggable executor strategy
|
Lazy-locking cast proxy for a wrapper or plain value reference. More...
#include <wrapper_cast.h>
Public Member Functions | |
| wrapper_caster (Refer ref) | |
Constructs the proxy, capturing references to every executor in the wrapper chain via an internal value_lock. No guard is acquired. | |
| ~wrapper_caster () | |
| Releases all guards acquired during conversion. | |
| operator Refer () && | |
Implicit conversion to the reference type Refer. | |
| template<typename T> requires ::scl::feature::concepts::convertible_from<T, Refer> | |
| T | to () && |
Acquires the guards needed to reach T and returns the value. | |
Lazy-locking cast proxy for a wrapper or plain value reference.
wrapper_caster<Refer> holds a value_lock (all executor references captured, no guard acquired yet) and exposes implicit conversion operators for every reachable level in the wrapper chain. Guards are activated only at the moment of conversion.
The proxy must be used as an rvalue; all conversion operators are &&-qualified.
auto p = wrapper_cast(makeW()); leaves p referring to a destroyed wrapper once that full-expression ends.| Refer | Reference type passed to wrapper_cast(). |
|
explicit |
Constructs the proxy, capturing references to every executor in the wrapper chain via an internal value_lock. No guard is acquired.
| ref | Reference to the outermost wrapper or plain value. |
| scl::wrapper_caster< Refer >::~wrapper_caster | ( | ) |
Releases all guards acquired during conversion.
If a conversion operator was invoked, the internal value_lock releases all held guards in reverse order (innermost first). If no conversion was performed, no guards are released.
|
nodiscard |
Implicit conversion to the reference type Refer.
Activates guards for all wrapper layers needed to reach the target type and returns the value. The proxy must be an rvalue at the call site.
One overload is available for each type reachable in the wrapper chain (the wrapper itself, its value_type, and so on recursively).
wrapper_caster is destroyed, not until the end of the conversion expression.
|
nodiscard |
Acquires the guards needed to reach T and returns the value.
| T | Target reference type — must be reachable from Refer via concepts::convertible_from. |
The proxy must be an rvalue at the call site.
wrapper_caster is destroyed.