equivalent of C++ implicit constructors and conversion operators

#ponce spam at spam.spam
Fri Apr 23 09:22:06 PDT 2010


In C++ implicit constructors and conversion operators allow a user-defined type to act quite like a builtin-type.

  struct half
  {
      half(float x);l
      inline operator float() const;
  }

allows to write:

  half x = 1.f;
  float f = x;

and this is especially useful for templates. 
I couldn't find a similar construct in D, is there any?


More information about the Digitalmars-d-learn mailing list