"ScL Feature"
/
ScL Feature
0.0.1
C++20 composable proxy wrapper with pluggable executor strategy
Toggle main menu visibility
Loading...
Searching...
No Matches
plain.h
Go to the documentation of this file.
1
#pragma once
2
6
7
#include <concepts>
8
#include <functional>
9
#include <utility>
10
11
#include <scl/utility/type_traits/forward_like.h>
12
13
#define SCL_EXECUTOR_CONSTRUCTOR_FOR_SELF_PROTOTYPE(cv_ref) \
14
constexpr explicit plain(self_type cv_ref other)
/**/
\
15
noexcept(::std::is_nothrow_constructible_v<value_type, value_type cv_ref>) \
16
requires(::std::constructible_from<value_type, value_type cv_ref>) \
17
: m_value{::std::forward<value_type cv_ref>(other.m_value)} \
18
{}
19
25
#define SCL_EXECUTOR_CONSTRUCTOR_FOR_SELF \
26
SCL_EXECUTOR_CONSTRUCTOR_FOR_SELF_PROTOTYPE(&) \
27
SCL_EXECUTOR_CONSTRUCTOR_FOR_SELF_PROTOTYPE(const &) \
28
SCL_EXECUTOR_CONSTRUCTOR_FOR_SELF_PROTOTYPE(volatile &) \
29
SCL_EXECUTOR_CONSTRUCTOR_FOR_SELF_PROTOTYPE(const volatile &) \
30
SCL_EXECUTOR_CONSTRUCTOR_FOR_SELF_PROTOTYPE(&&) \
31
SCL_EXECUTOR_CONSTRUCTOR_FOR_SELF_PROTOTYPE(const &&) \
32
SCL_EXECUTOR_CONSTRUCTOR_FOR_SELF_PROTOTYPE(volatile &&) \
33
SCL_EXECUTOR_CONSTRUCTOR_FOR_SELF_PROTOTYPE(const volatile &&)
34
35
namespace
scl::feature::inplace
36
{
50
// NOLINTBEGIN(cppcoreguidelines-special-member-functions, cppcoreguidelines-missing-std-forward, cppcoreguidelines-c-copy-assignment-signature)
51
template
<
typename
Value>
52
class
plain
53
{
54
using
self_type = plain<Value>;
55
56
public
:
57
using
value_type = Value;
58
59
public
:
60
template
<
typename
... Args>
61
constexpr
explicit
plain(Args &&... args)
62
: m_value{::std::forward<Args>(args)...}
63
{}
64
65
SCL_EXECUTOR_CONSTRUCTOR_FOR_SELF
66
67
// An executor carries no assignment operator of its own; assignment is
68
// performed value-semantically by the wrapper through execute().
69
plain & operator=(plain
const
&) =
delete
;
70
plain & operator=(plain &&) =
delete
;
71
72
public
:
73
template
<
typename
Self,
typename
Func,
typename
... Args>
74
static
constexpr
decltype
(
auto
) execute(Self && self, Func && func, Args &&... args)
75
requires
(::std::same_as<::std::remove_cvref_t<Self>, self_type> && ::std::invocable<Func, Args && ...>)
76
{
77
return ::std::invoke(::std::forward<Func>(func), ::std::forward<Args>(args)...);
78
}
79
80
template
<
typename
Self>
81
static
constexpr
decltype
(
auto
) access(Self && self)
82
requires ::std::same_as<::std::remove_cvref_t<Self>, self_type>
83
{
84
return ::scl::forward_like<Self>(self.m_value);
85
}
86
87
private
:
88
value_type m_value;
89
};
90
// NOLINTEND(cppcoreguidelines-special-member-functions, cppcoreguidelines-missing-std-forward, cppcoreguidelines-c-copy-assignment-signature)
91
}
// namespace scl::feature::inplace
92
93
#undef SCL_EXECUTOR_CONSTRUCTOR_FOR_SELF
94
#undef SCL_EXECUTOR_CONSTRUCTOR_FOR_SELF_PROTOTYPE
src
scl
feature
executor
inplace
plain.h
Generated by
1.18.0