Weird error when compiling.

bearophile bearophileHUGS at lycos.com
Sun Oct 20 17:13:58 PDT 2013


Agustin:

> Sorry i clicked the post button :(. The full code is:

I don't see your error with the following code, please give the 
code that gives the error, so we can fix the compiler bug:


public class Component {
       ////////////////////////////////////////////////////////////
       /// Component's unique id.
       private hash_t id;
       ....
       ////////////////////////////////////////////////////////////
       /// \brief Default constructor.
       ///
       /// \param[in] id   The id of the component
       ////////////////////////////////////////////////////////////
       public this(hash_t id) {
           this.id = id;
           this.active = true;
           this.validated = true;
       }

       ....
}

public class ComponentDetail(T) : Component {
       ////////////////////////////////////////////////////////////
       /// Component's ID as static member.
       public static hash_t ID = typeid(T).toHash;

       ////////////////////////////////////////////////////////////
       /// \brief Default constructor.
       ////////////////////////////////////////////////////////////
       public this() {
           super(ID);
       }
}

private class InputComponent : ComponentDetail!InputComponent {
}

void main() {
       auto pComponent = new InputComponent();

       writeln(pComponent.getId());
       writeln(InputComponent.ID);
}



Bye,
bearophile


More information about the Digitalmars-d-learn mailing list