File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -2973,7 +2973,7 @@ class OPTION_DECLSPEC_EMPTY_BASES OPTION_CONSUMABLE(unconsumed) option
29732973 constexpr option& operator =(const option<U>& other) {
29742974 if constexpr (std::is_reference_v<T>) {
29752975 if (other.has_value ()) {
2976- base::value = base::ref_to_ptr (static_cast <option<U>&&>( other.get () ));
2976+ base::value = base::ref_to_ptr (other.get ());
29772977 } else {
29782978 reset ();
29792979 }
Original file line number Diff line number Diff line change @@ -259,6 +259,17 @@ TEST_CASE("reference") {
259259 }
260260 // NOLINTEND(misc-const-correctness)
261261 }
262+ SUBCASE (" operator=" ) {
263+ int val = 1 ;
264+ opt::option<int &> a;
265+ const opt::option<std::reference_wrapper<int >> b{val};
266+ a = b;
267+ CHECK_EQ (a, val);
268+ CHECK_EQ (a.ptr_or_null (), &val);
269+ a = opt::option{std::ref (val)};
270+ CHECK_EQ (a, val);
271+ CHECK_EQ (a.ptr_or_null (), &val);
272+ }
262273}
263274
264275// NOLINTBEGIN(performance-move-const-arg,bugprone-use-after-move)
You can’t perform that action at this time.
0 commit comments