Steven Schveighoffer wrote: > On Wed, 27 Oct 2010 16:26:21 -0400, div0 <d...@sourceforge.net> wrote: > >> class Foo(T) { >> this(T t) { >> bar = t; >> } >> >> this(string x) { >> } >> >> this(int x) { >> } >> >> T bar; >> } >> >> auto f0 = new Foo("wtf?"); >> auto f1 = new Foo(42); >> >> What's T in any of the above? > > translates to: > auto f0 = new Foo!(string)("wtf?"); > auto f0 = new Foo!(int)(42); > > Both of which error, since T can be neither int nor string, or Foo would > contain conflicting constructors. > > Your question is akin to asking why IFTI doesn't work on something like > this: > > T foo(T)(int x); > > What Jerome was referring to is something like this: > > class Foo(T) > { > this(T t) {} > this(T t, string x); > } > > which should be unambiguous and completely doable. > > The thing is, when a templated class is to be instantiated without > giving a complete set of template arguments, then it should use IFTI. > The decision to try IFTI is not ambiguous, but depending on how you > implement the constructors, the overloading can be ambiguous. > Exactly, it should be possible to have consistent behaviour for template class constructors and template functions: they should both work and fail in similar circumstances.
Jerome -- mailto:jeber...@free.fr http://jeberger.free.fr Jabber: jeber...@jabber.fr
signature.asc
Description: OpenPGP digital signature