Weird error when compiling.
Agustin
agustin.l.alvarez at hotmail.com
Sat Oct 19 18:59:47 PDT 2013
On Sunday, 20 October 2013 at 01:56:39 UTC, TheFlyingFiddle wrote:
>> public class ComponentDetail(T) : Component {
>>
>> ////////////////////////////////////////////////////////////
>> /// Component's ID as static member.
>> public static hash_t ID = typeid(T).toHash;
>
> typeid(T).toHash can not be evaluated by the compiler at
> compile-time.
>
> Placing the ID initalization in a static this should fix the
> problem.
>
> eg.
>
> public static hash_t ID;
>
> static this()
> {
> ID = typeid(T).toHash;
> }
Anyway to evaluate the name of the class and return its hash at
compile time?
More information about the Digitalmars-d-learn
mailing list