"ScL Feature"/
SCL Feature 0.0.1
C++20 composable proxy wrapper with pluggable executor strategy
Loading...
Searching...
No Matches
wrapper_constructors.h
1#pragma once
2
3#include <concepts>
4#include <type_traits>
5
12// cppcheck-suppress noExplicitConstructor
13#define SCL_WRAPPER_CONSTRUCTOR_FOR_SELF_PROTOTYPE(cv_ref) \
14 constexpr wrapper(self_type cv_ref other) noexcept( \
15 ::std::is_nothrow_constructible_v<executor_type, executor_type cv_ref>) \
16 requires(::std::constructible_from<executor_type, executor_type cv_ref>) \
17 : m_executor{::scl::forward_like<self_type cv_ref>(other.m_executor)} \
18 {}
19
25#define SCL_WRAPPER_CONSTRUCTOR_FOR_SELF \
26 SCL_WRAPPER_CONSTRUCTOR_FOR_SELF_PROTOTYPE(&) \
27 SCL_WRAPPER_CONSTRUCTOR_FOR_SELF_PROTOTYPE(const &) \
28 SCL_WRAPPER_CONSTRUCTOR_FOR_SELF_PROTOTYPE(volatile &) \
29 SCL_WRAPPER_CONSTRUCTOR_FOR_SELF_PROTOTYPE(const volatile &) \
30 SCL_WRAPPER_CONSTRUCTOR_FOR_SELF_PROTOTYPE(&&) \
31 SCL_WRAPPER_CONSTRUCTOR_FOR_SELF_PROTOTYPE(const &&) \
32 SCL_WRAPPER_CONSTRUCTOR_FOR_SELF_PROTOTYPE(volatile &&) \
33 SCL_WRAPPER_CONSTRUCTOR_FOR_SELF_PROTOTYPE(const volatile &&)
34
41// cppcheck-suppress noExplicitConstructor
42#define SCL_WRAPPER_CONSTRUCTOR_FOR_OTHER \
43 template <typename Other> \
44 constexpr wrapper(Other && other) noexcept( \
45 noexcept(::std::declval<wrapper_constructor_resolver<self_type, Other &&>>().resolve())) \
46 requires(::scl::feature::is_wrapper_v<::std::remove_cvref_t<Other>> && \
47 !::std::same_as<::std::remove_cvref_t<Other>, self_type> && \
48 ::std::constructible_from<executor_type, \
49 decltype(::std::declval<wrapper_constructor_resolver<self_type, Other &&>>().resolve())>) \
50 : m_executor{wrapper_constructor_resolver<self_type, Other &&>{::std::forward<Other>(other)}.resolve()} \
51 {}