#pragma once #include namespace jvalidate::detail { constexpr struct discard_out_t { } discard_out; template class out { private: T * ref_ = nullptr; public: out() = default; out(discard_out_t) {} out(T & ref) : ref_(&ref) {} explicit operator bool() const { return ref_; } void operator=(T && val) { if (ref_) { *ref_ = std::move(val); } return *this; } void operator=(T const & val) { if (ref_) { *ref_ = val; } return *this; } }; }