|
SCL Feature 0.0.1
C++20 composable proxy wrapper with pluggable executor strategy
|
Compile-time method reflection macros for wrapper types. More...
Go to the source code of this file.
Macros | |
| #define | SCL_REFLECT_METHOD(method) |
Generates proxy methods that reflect method from the wrapped object through the executor, for all 8 cv-ref qualifier combinations. | |
Compile-time method reflection macros for wrapper types.
Provides macros to automatically generate proxy methods that forward calls from a wrapper class to the held object through an executor, preserving cv-ref qualifiers exactly.
The executor is located at runtime via scl::feature::executor_trait, which must be specialized for each wrapper type.
SCL_REFLECT_TYPE(Type,Member) (after the executor member declaration).scl::feature::executor_trait for the wrapper type.value(exec) method that returns a reference to the wrapped object.| #define SCL_REFLECT_METHOD | ( | method | ) |
Generates proxy methods that reflect method from the wrapped object through the executor, for all 8 cv-ref qualifier combinations.
For each of the 8 cv-ref qualifiers (&, &&, const&, const&&, volatile&, volatile&&, const volatile&, const volatile&&) two overloads are generated:
template<typename... A_r_g_s__>template<typename\ P_a_r_a_m__,\ typename... P_a_r_a_m_s__,\ typename... A_r_g_s__>This gives 16 overloads in total (2 × 8).
scl::feature::executor_trait<WrapperType>::executor(self). The default trait returns self.m_executor. Specialize the trait for types that store the executor differently.The wrapped value is then obtained by calling Executor::value(executor_ref).
requires clauses:method must be callable with the given arguments for the particular cv-ref qualification.SCL_HAS_QUALIFIED_METHOD must confirm that the wrapped object has a dedicated overload for that qualifier (not an implicit cv-widening fallback). This prevents, for example, a const& proxy from being generated when only a mutable & overload exists on the target.SCL_HAS_QUALIFIED_METHOD relies on return-type discrimination, overloads of the target method with different cv-ref qualifiers must return different types. If two overloads return the same type, the macro will produce a false negative. method is a template on the wrapped object (e.g. template<typename\ T>\ T\ convert()), users can call the reflected method with explicit template arguments: wrapper.convert<double>().Internally this is handled by a helper struct (METHOD_S_c_L_caller_) generated inside the enclosing class. The struct wraps the .template method<...> call inside a static function template whose object parameter (O_b_j___) is dependent. This ensures that the template keyword appears only in a dependent context, so the compiler defers name lookup to instantiation time. Without this indirection, .template foo<...> on a non-dependent type where foo is not a template would be a hard parse error (not SFINAE), even inside a requires expression.
When method is not a template, the helper struct's call function fails to instantiate (SFINAE via trailing return type), the requires clause evaluates to false, and the explicit-template-args overload is silently discarded.
| method | Unqualified method name (plain identifier). |