| 12345678910111213141516171819202122232425262728293031323334 |
- #pragma once
- #include <utility>
- namespace jvalidate::detail {
- constexpr struct discard_out_t {
- } discard_out;
- template <typename T> 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;
- }
- };
- }
|