scl-feature

ScL.Feature

GitLab Pipeline GitLab Pages GitHub Pages

C++20 header-only library. Part of the ScL Toolkit.

ScL.Feature provides scl::wrapper<Value, Executors...> — a composable proxy wrapper that delegates method calls to the held value through a chain of executor templates. Each executor can transparently add cross-cutting behaviour such as copy-on-write semantics, thread safety, or deferred invocation without modifying the wrapped type. Licensed under The Unlicense.

Features

Requirements

Installation

Add the module as a subdirectory and link against the interface target:

add_subdirectory(module/feature)
target_link_libraries(your_target PRIVATE scl::feature)

Quick example

Reflection

#include <scl/feature/reflection/method.h>
#include <scl/feature/inplace/plain.h>

struct Target {
    short get() &;
    int   get() const &;
    float get() &&;
};

struct MyWrapper {
    Executor<Target> m_executor; // any executor
    SCL_REFLECT_TYPE(MyWrapper, m_executor);

    SCL_REFLECT_METHOD(get)  // generates 16 overloads, 3 survive constraints
};

MyWrapper w{42};
w.get();               // Target::get() &       → short
std::as_const(w).get() // Target::get() const & → int
std::move(w).get();    // Target::get() &&      → float

Doxygen

See also