Implicit conversion in constructor
    rcorre via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Fri Jul 17 19:23:25 PDT 2015
    
    
  
Is there any reason why implicit conversion from Foo to Thing is 
permitted in a regular method but not in a constructor?
Trying to figure out whether this is a bug or some sort of 
constructor-specific safety precaution.
struct Thing {
   Foo foo;
   alias foo this;
}
class Foo { }
class Bar {
   Thing thing;
   void fine() {
     thing = new Foo(); // ok
   }
   this() {
     thing = new Foo(); // nope!
   }
}
    
    
More information about the Digitalmars-d-learn
mailing list