__rvalref overloads causing ambiguities

chris jefferson caj@cs.york.ac.uk
Wed Jul 27 20:28:00 GMT 2005


Here is an attempt at a patch to fix the rvalref ambiguities.

I decided to change the constructors as well as the operator=. The
constructors weren't causing a problem with this testcase, as there are
already at least 2 standard-supplied constructors for each container
(one taking the container, one taking an allocator). However templating
them might stop other problems later. If someone with more template-foo
than me thinks it would be safer to leave them as-is, I'm happy to
change them back.

Johnathan: I assume you a) have no problems with being put on the
changelog, and b) I referenced you correctly?

I think the new error message is OK (or at least as OK as error messages
in the STL ever get...)

The error message has changed from (for assigning an rvalue of a list to
a vector say)

t.cc:10: error: no match for 'operator=' in 'a = __gnu_cxx::__move [with
_Tp = std::list<int, std::allocator<int> >](((std::list<int,
std::allocator<int> >&)(& b)))'
/gcccvs/lib/gcc/powerpc-apple-darwin8.1.0/4.1.0/../../../../include/c++/4.1.0/bits/vector.tcc:133:
note: candidates are: std::vector<_Tp, _Alloc>& std::vector<_Tp,
_Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int,
_Alloc = std::allocator<int>]
/gcccvs/lib/gcc/powerpc-apple-darwin8.1.0/4.1.0/../../../../include/c++/4.1.0/bits/stl_vector.h:303:
note:                 std::vector<_Tp, _Alloc>& std::vector<_Tp,
_Alloc>::operator=(__gnu_cxx::__rvalref<std::vector<_Tp, _Alloc> >)
[with _Tp = int, _Alloc = std::allocator<int>]

to:

/cleangcc/lib/gcc/powerpc-apple-darwin8.1.0/4.1.0/../../../../include/c++/4.1.0/bits/stl_vector.h:
In member function 'std::vector<_Tp, _Alloc>& std::vector<_Tp,
_Alloc>::operator=(__gnu_cxx::__rvalref<_Vector>) [with _Vector =
std::list<int, std::allocator<int> >, _Tp = int, _Alloc =
std::allocator<int>]':
t.cc:10:   instantiated from here
/cleangcc/lib/gcc/powerpc-apple-darwin8.1.0/4.1.0/../../../../include/c++/4.1.0/bits/stl_vector.h:313:
error: no matching function for call to 'std::vector<int,
std::allocator<int> >::swap(std::list<int, std::allocator<int> >&)'
/cleangcc/lib/gcc/powerpc-apple-darwin8.1.0/4.1.0/../../../../include/c++/4.1.0/bits/stl_vector.h:748:
note: candidates are: void std::vector<_Tp,
_Alloc>::swap(std::vector<_Tp, _Alloc>&) [with _Tp = int, _Alloc =
std::allocator<int>]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Changelog-rvalref
Type: application/text
Size: 974 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20050727/3f2ac433/attachment.bin>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch-rvalref
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20050727/3f2ac433/attachment.ksh>


More information about the Libstdc++ mailing list