|
|
@@ -9,7 +9,8 @@ constexpr struct discard_out_t {
|
|
|
} discard_out;
|
|
|
|
|
|
template <typename T>
|
|
|
-requires(std::is_same_v<T, std::decay_t<T>>) class out {
|
|
|
+ requires(std::is_same_v<T, std::decay_t<T>>)
|
|
|
+class out {
|
|
|
private:
|
|
|
T * ref_ = nullptr;
|
|
|
|
|
|
@@ -21,7 +22,7 @@ public:
|
|
|
explicit operator bool() const { return ref_; }
|
|
|
|
|
|
template <typename U>
|
|
|
- requires std::is_constructible_v<T, U>
|
|
|
+ requires std::is_constructible_v<T, U>
|
|
|
void operator=(U && val) {
|
|
|
if (ref_) {
|
|
|
*ref_ = std::forward<U>(val);
|
|
|
@@ -31,7 +32,8 @@ public:
|
|
|
};
|
|
|
|
|
|
template <typename T>
|
|
|
-requires(std::is_same_v<T, std::decay_t<T>>) class inout {
|
|
|
+ requires(std::is_same_v<T, std::decay_t<T>>)
|
|
|
+class inout {
|
|
|
private:
|
|
|
std::variant<T, T *> ref_;
|
|
|
|
|
|
@@ -48,14 +50,14 @@ public:
|
|
|
}
|
|
|
|
|
|
template <typename U>
|
|
|
- requires std::is_constructible_v<T, U> T const & operator=(U && val) {
|
|
|
+ requires std::is_constructible_v<T, U>
|
|
|
+ T const & operator=(U && val) {
|
|
|
struct {
|
|
|
U && val;
|
|
|
- void operator()(T & in) const { in = std::forward<U>(val); }
|
|
|
- void operator()(T * in) const { *in = std::forward<U>(val); }
|
|
|
+ T const & operator()(T & in) const { return in = std::forward<U>(val); }
|
|
|
+ T const & operator()(T * in) const { return *in = std::forward<U>(val); }
|
|
|
} visitor{std::forward<U>(val)};
|
|
|
- std::visit(visitor, ref_);
|
|
|
- return static_cast<T const &>(*this);
|
|
|
+ return std::visit(visitor, ref_);
|
|
|
}
|
|
|
};
|
|
|
}
|