"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#ifndef DOXYGEN
4
5#include <scl/feature/detail/wrapper.h>
7
8#include <type_traits>
9
10namespace scl::feature::detail
11{
12 template <typename State, template <typename> class... Executor>
13 struct wrapper_fold
14 {
15 using type = State;
16 };
17
18 template <typename State, template <typename> class Executor, template <typename> class... Rest>
19 struct wrapper_fold<State, Executor, Rest...>
20 {
21 using type = typename wrapper_fold<::scl::feature::detail::wrapper<State, Executor>, Rest...>::type;
22 };
23
24 template <typename Value, template <typename> class Executor, template <typename> class... Rest>
25 struct wrapper_fold<::scl::feature::detail::wrapper<Value, Executor>, Executor, Rest...>
26 {
27 using type = typename wrapper_fold<::scl::feature::detail::wrapper<Value, Executor>, Rest...>::type;
28 };
29} // namespace scl::feature::detail
30
31namespace scl
32{
33 template <typename Value, template <typename> class... Executors>
34 using wrapper = ::std::conditional_t<sizeof...(Executors) == 0,
35 typename ::scl::feature::detail::wrapper_fold<Value, ::scl::feature::inplace::plain>::type,
36 typename ::scl::feature::detail::wrapper_fold<Value, Executors...>::type>;
37} // namespace scl
38
39#else // DOXYGEN
40
41namespace scl
42{
46
70 template <typename Value, template <typename> class... Executors>
71 class wrapper
72 {
73 public:
75 using value_type = Value;
76
78 using executor_type = /* implementation defined */;
79
86 constexpr wrapper()
87 requires ::std::default_initializable<executor_type>;
88
98 template <typename... Args>
99 constexpr explicit wrapper(Args &&... args)
100 requires ::std::constructible_from<executor_type, Args...>;
101
114 constexpr wrapper(wrapper & other)
115 requires ::std::constructible_from<executor_type, executor_type &>;
117 constexpr wrapper(wrapper const & other)
118 requires ::std::constructible_from<executor_type, executor_type const &>;
120 constexpr wrapper(wrapper volatile & other)
121 requires ::std::constructible_from<executor_type, executor_type volatile &>;
123 constexpr wrapper(wrapper const volatile & other)
124 requires ::std::constructible_from<executor_type, executor_type const volatile &>;
126 constexpr wrapper(wrapper && other)
127 requires ::std::constructible_from<executor_type, executor_type &&>;
129 constexpr wrapper(wrapper const && other)
130 requires ::std::constructible_from<executor_type, executor_type const &&>;
132 constexpr wrapper(wrapper volatile && other)
133 requires ::std::constructible_from<executor_type, executor_type volatile &&>;
135 constexpr wrapper(wrapper const volatile && other)
136 requires ::std::constructible_from<executor_type, executor_type const volatile &&>;
137
150 template <concepts::wrapper Other>
151 constexpr wrapper(Other && other)
152 requires(!::std::same_as<::std::remove_cvref_t<Other>, wrapper> &&
153 ::std::constructible_from<executor_type,
154 decltype(wrapper_constructor_resolver<wrapper, Other &&>{other}.resolve())>);
155 };
156 // end of group scl_feature_wrapper
158} // namespace scl
159
160#endif // DOXYGEN
Composable proxy wrapper that delegates to Value through executors.
Definition wrapper.h:72
constexpr wrapper(wrapper const volatile &&other)
Copy / move construction from the same wrapper type.
constexpr wrapper(wrapper volatile &other)
Copy / move construction from the same wrapper type.
constexpr wrapper(Other &&other)
Converting construction from a compatible wrapper type.
constexpr wrapper(wrapper &other)
Copy / move construction from the same wrapper type.
typedef executor_type
The outermost executor instantiation — Executor<value_type>.
Definition wrapper.h:78
constexpr wrapper(wrapper const volatile &other)
Copy / move construction from the same wrapper type.
constexpr wrapper()
Default construction — default-initialises the executor.
constexpr wrapper(wrapper const &other)
Copy / move construction from the same wrapper type.
constexpr wrapper(Args &&... args)
Direct construction — forwards all arguments to the executor.
constexpr wrapper(wrapper &&other)
Copy / move construction from the same wrapper type.
constexpr wrapper(wrapper const &&other)
Copy / move construction from the same wrapper type.
constexpr wrapper(wrapper volatile &&other)
Copy / move construction from the same wrapper type.
Value value_type
The wrapped value type.
Definition wrapper.h:75
Root namespace of the ScL project.
Executor that proxies calls directly to the held value with no overhead.