* libstdc++-v3/include/std/variant (variant::operator=): Fix assignment
on references.
* libstdc++-v3/testsuite/20_util/variant/compile.cc: Add test.
From-SVN: r240343
+2016-09-22 Tim Shen <timshen@google.com>
+
+ * libstdc++-v3/include/std/variant (variant::operator=): Fix assignment
+ on references.
+ * libstdc++-v3/testsuite/20_util/variant/compile.cc: Add test.
+
2016-09-22 Tim Shen <timshen@google.com>
PR libstdc++/77641
{
constexpr auto __index = __accepted_index<_Tp&&>;
if (index() == __index)
- *static_cast<__storage<__to_type<__index>>*>(this->_M_storage())
- = forward<_Tp>(__rhs);
+ std::get<__index>(*this) = std::forward<_Tp>(__rhs);
else
this->emplace<__index>(forward<_Tp>(__rhs));
__glibcxx_assert(holds_alternative<__accepted_type<_Tp&&>>(*this));
variant<DefaultNoexcept> a;
static_assert(!noexcept(a = a), "");
}
+
+ {
+ float f1 = 1.0f, f2 = 2.0f;
+ std::variant<float&> v1(f1);
+ v1 = f2;
+ }
}
void move_assign()