[PATCH] libstdc++/77641 fix std::variant for literal types
Jonathan Wakely
jwakely@redhat.com
Thu Sep 22 08:38:00 GMT 2016
On 22/09/16 09:37 +0100, Jonathan Wakely wrote:
>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.
Oh I missed Tim's patch for this that he already posted.
More information about the Libstdc++
mailing list