This was approved at the October 2021 plenary.
libstdc++-v3/ChangeLog:
* include/std/variant (variant::operator=): Implement resolution
of LWG 3585.
* testsuite/20_util/variant/lwg3585.cc: New test.
|| !is_nothrow_move_constructible_v<_Tj>)
this->emplace<__index>(std::forward<_Tp>(__rhs));
else
- operator=(variant(std::forward<_Tp>(__rhs)));
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 3585. converting assignment with immovable alternative
+ this->emplace<__index>(_Tj(std::forward<_Tp>(__rhs)));
}
return *this;
}
--- /dev/null
+// { dg-do compile { target c++17 } }
+
+// LWG 3585. Variant converting assignment with immovable alternative
+
+#include <variant>
+#include <string>
+
+struct A {
+ A() = default;
+ A(A&&) = delete;
+};
+
+int main() {
+ std::variant<A, std::string> v;
+ v = "hello";
+}