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: __rvalref overloads causing ambiguities


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


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