Implicit conversion error using g++
Alexandre Oliva
aoliva@redhat.com
Mon Jul 9 15:11:00 GMT 2001
On Jul 9, 2001, David Berthelot <davidb@Magma-DA.COM> wrote:
> Alexandre Oliva wrote:
>> Nope. Both lines perform object initialization, so the assignment
>> operator plays no role. The difference is that `Baz b1(bar)' is a
>> direct initialization, whereas `Baz b2 = bar' is a copy
>> initialization. The former may use a user-defined conversion sequence
>> plus a constructor, but the latter needs a single user-defined
>> conversion sequence, that can contain either a constructor or a
>> conversion function. See [dcl.init]/11-14 for details.
> Ok, I get it. In fact line 14 would translate by:
> - Baz(const Foo&) (right hand side of equal)
> - Baz(const Baz&) (for b2)
> Am I correct ?
Yep
> So the code is supposed to work ?
Nope, because a user-defined conversion sequence can involve no more
than a single constructor *or* a single user-defined conversion
function.
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist *Please* write to mailing lists, not to me
More information about the Gcc-help
mailing list