This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] libstdc++/77641 fix std::variant for literal types


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]