No constructor for a templated class?

Mafi mafi at example.org
Sun Jul 25 15:00:31 PDT 2010


Am 25.07.2010 14:55, schrieb Philippe Sigaud:
> OK, I must be tired, I don't know.
> While switching from a template struct to a templated class, I got the
> following problem:
>
> class A(T)
> {
>      T _t;
>      this(U)(U u) if (is(U == T))
>      {
>          _t = u;
>      }
> }

Probably this case is reduced, but anyways:
Having a template(U) where U must be == T (another template parameter) 
is complettly useless. Maybe I'm missing something but isn't this 
equivalent to the above:
class A(T)
  {
       T _t;
       this(T u)
       {
           _t = u;
       }
  }



More information about the Digitalmars-d-learn mailing list