This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: __rvalref overloads causing ambiguities
- From: chris jefferson <caj at cs dot york dot ac dot uk>
- To: Jonathan Wakely <cow at compsoc dot man dot ac dot uk>
- Cc: libstdc++ at gcc dot gnu dot org
- Date: Thu, 21 Jul 2005 10:30:42 +0100
- Subject: Re: __rvalref overloads causing ambiguities
- References: <20050720163527.GA41151@compsoc.man.ac.uk>
Jonathan Wakely wrote:
>Hi Chris,
>
>It looks like your rvalue references that provide move semantics
>can cause ambiguous overloads.
>
>
>
Woops, I missed this. I've been planning to try to get boost to compile
/ test for a while..
>...
>
>Could you add another level of indirection, so that going from A to
>rvalref<vector> would require two user-defined conversions (which won't
>happen implicitly) ?
>
>
>
We can't add another level of indirection like you say. I believe we can
use some templates to confuse the compiler into ignoring the problem
however. I'm currently testing something very much like:
template<class T,class U = void>
struct __rvalref;
...
(inside vector)
template<class U>
vector(__rvalref<vector,U>);
This should make sure that you never automatically try this constructor
(or operator=, which is defined similarily), but only use them when you
have a "real" __rvalref.
It is of course just a little hacky, but compiles away to no extra
overhead (modulo a random "void" appearing in the debug information").
I'll run through a testsuite, and see if anything else crops up. Thanks
for finding this :)
Chris