"ScL Feature"/
ScL Feature 0.0.1
C++20 composable proxy wrapper with pluggable executor strategy
Loading...
Searching...
No Matches
reflect.h File Reference

Primary template for the reflection mixin chain. More...

Go to the source code of this file.

Classes

class  scl::feature::reflect< Wrapper, Executor, Type >
 Primary (terminal) template for the reflection mixin chain. More...
class  scl::feature::reflect_operators< Wrapper, Executor >
 CRTP mixin that reflects all standard C++ operators through the executor. More...

Namespaces

namespace  scl
 Root namespace of the ScL project.
namespace  scl::feature
 Namespace of the ScL Feature module.

Detailed Description

Primary template for the reflection mixin chain.

Defines scl::feature::reflect<Wrapper, Executor, Type> — the CRTP mixin base that detail::wrapper inherits from to acquire all proxy members reflected for the held value type.

How the chain works

detail::wrapper<Value, Executor> publicly inherits:

reflect<wrapper<Value,Executor>, Executor<Value>, wrapper<Value,Executor>>

Two partial specialisations (defined in detail/wrapper.h) peel the detail::wrapper layer off the third parameter:

  1. cv/ref-strip — detail::wrapper<QualifiedInner, E> (where QualifiedInner carries cv/ref qualifiers) delegates to the unqualified form, collapsing all 12 variants into one rule.
  2. Chain delegation — detail::wrapper<Value, E> (unqualified inner) inherits from reflect<Wrapper, Executor, Value>, propagating all members reflected for Value up to the outer wrapper.

The primary template (this file) is the terminal case: when Type is neither a detail::wrapper specialisation nor any other specialised form, the class body is empty. User-provided specialisations extend this chain for concrete value types.

Extending for a custom type

Specialise reflect for your value type. SCL_REFLECT_TYPE must appear first to establish the internal type context that SCL_REFLECT_METHOD depends on:

template <typename Wrapper, typename Executor>
class scl::feature::reflect<Wrapper, Executor, MyValue>
{
SCL_REFLECT_TYPE(Wrapper, Executor)
SCL_REFLECT_METHOD(my_method)
};
Primary (terminal) template for the reflection mixin chain.
Definition reflect.h:76
#define SCL_REFLECT_TYPE(type, executor)
Declares the wrapper and executor types for use by SCL_REFLECT_METHOD.
Definition type.h:27
#define SCL_REFLECT_METHOD(name)
Generates proxy methods that reflect method from the wrapped object through the executor,...
Definition method.h:427