"ScL Feature"/
ScL Feature 0.0.1
C++20 composable proxy wrapper with pluggable executor strategy
Loading...
Searching...
No Matches
wrapper.h
1#pragma once
2
3#include <scl/feature/concepts/executor.h>
4#include <scl/feature/concepts/wrapper.h>
5#include <scl/feature/detail/executor_access.h>
6#include <scl/feature/detail/wrapper_constructor_resolver.h>
7#include <scl/feature/detail/wrapper_constructors.h>
9#include <scl/utility/attribute.h>
10
11#include <utility>
12
13namespace scl::feature::detail
14{
15 // NOLINTBEGIN(cppcoreguidelines-special-member-functions, cppcoreguidelines-c-copy-assignment-signature)
16 template <typename Value, template <typename> class Executor>
17 requires ::scl::feature::concepts::executor<Executor<Value>>
18 class wrapper
19 : public ::scl::feature::reflect<wrapper<Value, Executor>, Executor<Value>, wrapper<Value, Executor>>
20 , public ::scl::feature::reflect_operators<wrapper<Value, Executor>, Executor<Value>>
21 {
22 using self_type = wrapper<Value, Executor>;
23
24 public:
25 using value_type = Value;
26 using executor_type = Executor<value_type>;
27
28 private:
29 SCL_NO_UNIQUE_ADDRESS
30 executor_type m_executor;
31
32 friend struct executor_access;
33
34 public:
36 template <typename... Args>
37 constexpr explicit wrapper(Args &&... args)
38 : m_executor{::std::forward<Args>(args)...}
39 {}
40
41 // clang-format off
42 SCL_REFLECT_TYPE(self_type, executor_type)
43
44 // cppcheck-suppress noExplicitConstructor
45 SCL_WRAPPER_CONSTRUCTOR_FOR_SELF // NOLINT(performance-noexcept-move-constructor)
46 // cppcheck-suppress noExplicitConstructor
47 SCL_WRAPPER_CONSTRUCTOR_FOR_OTHER
48 SCL_WRAPPER_ASSIGNMENT_FOR_SELF
49 SCL_WRAPPER_ASSIGNMENT_FOR_OTHER
50 // clang-format on
51 };
52 // NOLINTEND(cppcoreguidelines-special-member-functions, cppcoreguidelines-c-copy-assignment-signature)
53} // namespace scl::feature::detail
54
60template <typename Value, template <typename> class Executor>
61struct scl::feature::executor_trait<::scl::feature::detail::wrapper<Value, Executor>>
62{
63 template <typename Self>
64 static constexpr decltype(auto) executor(Self && self) noexcept
65 {
66 return ::scl::feature::detail::executor_access::get(::std::forward<Self>(self));
67 }
68};
69
70namespace scl::feature
71{
79 template <typename Wrapper, typename Executor, typename QualifiedInner, template <typename> class OuterExecutor>
80 requires(::scl::feature::concepts::wrapper<QualifiedInner> &&
81 !::std::same_as<QualifiedInner, ::std::remove_cvref_t<QualifiedInner>>)
82 class reflect<Wrapper, Executor, detail::wrapper<QualifiedInner, OuterExecutor>>
83 : public reflect<Wrapper, Executor, detail::wrapper<::std::remove_cvref_t<QualifiedInner>, OuterExecutor>>
84 {};
85
91 template <typename Wrapper, typename Executor, typename Value, template <typename> class OuterExecutor>
92 class reflect<Wrapper, Executor, detail::wrapper<Value, OuterExecutor>>
93 : public reflect<Wrapper, Executor, Value>
94 {};
95} // namespace scl::feature
Primary (terminal) template for the reflection mixin chain.
Definition reflect.h:76
Composable proxy wrapper that delegates to Value through executors.
Definition wrapper.h:72
constexpr wrapper()
Default construction — default-initialises the executor.
#define SCL_REFLECT_TYPE(type, executor)
Declares the wrapper and executor types for use by SCL_REFLECT_METHOD.
Definition type.h:27
Namespace of the ScL Feature module.
Primary template for the reflection mixin chain.
Trait that provides access to the executor inside a wrapper.
Definition executor.h:39