------- Comment #16 from redi at gcc dot gnu dot org  2010-04-19 16:13 -------
Understood, but I don't see any way to fix that code.  std::make_pair has been
changed to handle rvalues, including deducing whether its arguments are lvalues
or rvalues.

By suppressing the type deduction you also suppress the lvalue/rvalue
deduction, so you had better get the types right, or you will try to bind an
rvalue to an lvalue.

It might be possible to provide an overload of make_pair which intentionally
can't deduce types and which only supports lvalues (like the old
std::make_pair) so that it will be chosen when the template args are given
explicitly:

template<class _T1, class _T2>
  inline pair<typename __decay_and_strip<_T1>::__type,
              typename __decay_and_strip<_T2>::__type>
  make_pair(const typename identity<_T1>::type& __x,
            const typename identity<_T2>::type&& __y)
  {
    return pair<typename __decay_and_strip<_T1>::__type,
              typename __decay_and_strip<_T2>::__type>(__x, __y);
  }

But it has taken so long to get pair to work correctly with rvalues that I
would be very cautious about changing anything now.  That overload could
introduce ambiguities I haven't considered.

My personal feeling is that it's better to break code misusing make_pair in
order to add rvalue support.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43785

Reply via email to