This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [PATCH] libstdc++/77641 fix std::variant for literal types
- From: Jonathan Wakely <jwakely at redhat dot com>
- To: Ville Voutilainen <ville dot voutilainen at gmail dot com>
- Cc: Tim Shen <timshen at google dot com>, libstdc++ <libstdc++ at gcc dot gnu dot org>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 22 Sep 2016 09:37:14 +0100
- Subject: Re: [PATCH] libstdc++/77641 fix std::variant for literal types
- Authentication-results: sourceware.org; auth=none
- References: <CAFk2RUbw4EDwrtpc+FVszb6oTrLNdh+=0_TkpJbctU3OYZZOBw@mail.gmail.com>
On 22/09/16 09:45 +0300, Ville Voutilainen wrote:
This problem is not introduced by the latest patch, but it's something that
we should look at anyway. There's been recent discussion about what
assignments do with variants that hold references. Consider this:
#include <variant>
int main()
{
float f1 = 1.0f, f2 = 2.0f;
std::variant<float&> v1(f1);
v1 = f2; // #1
}
It works if we add this to _Reference_storage:
template<typename _Tp>
_Reference_storage&
operator=(_Tp&& __t)
{
_M_storage = std::forward<_Tp>(__t);
return *this;
}
I'm not sure if that's the right fix.