File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -42,8 +42,6 @@ struct DefaultEmptyPredicate
4242 {
4343 return !t;
4444 }
45-
46-
4745};
4846
4947/* * A compact optional.
@@ -65,8 +63,27 @@ class Optional
6563
6664 constexpr Optional () = default;
6765 constexpr Optional (Optional const & other) = default;
66+
6867 constexpr Optional& operator =(Optional const & other) = default ;
6968 constexpr Optional& operator =(Optional&& other) = default ;
69+ constexpr Optional& operator =(T const & t)
70+ {
71+ t_ = t;
72+ return *this ;
73+ }
74+
75+ constexpr Optional& operator =(T&& t)
76+ {
77+ t_ = std::move (t);
78+ return *this ;
79+ }
80+
81+ constexpr Optional& operator =(std::nullptr_t )
82+ {
83+ t_ = T ();
84+ MRDOCS_ASSERT (!this ->operator bool ());
85+ return *this ;
86+ }
7087
7188 template <class U >
7289 requires std::is_constructible_v<T, U>
@@ -79,6 +96,7 @@ class Optional
7996 constexpr void reset ()
8097 {
8198 *this = Optional ();
99+ MRDOCS_ASSERT (!this ->operator bool ());
82100 }
83101
84102 template <typename ... Args>
You can’t perform that action at this time.
0 commit comments