equivalent of typeid(Class).name at compile-time

Steven Schveighoffer schveiguy at gmail.com
Thu Nov 21 20:45:16 UTC 2019


On 11/21/19 3:44 PM, Steven Schveighoffer wrote:
> I thought I could do typeid(Class).name to get the class name that will 
> be returned at runtime if you did typeid(instance).name. But it's not 
> accessible at compile-time.
> 
> What compile-time string should I use for instance in a constructed 
> switch statement? I'm trying to implement serialization and 
> deserialization of classes, but I really would like to avoid using a 
> class enum if possible, since the type id is already there and generated 
> by the compiler.

To clarify, I need the compile time string that will match 
typeid(instance).name, so I can match the derived type.

-Steve


More information about the Digitalmars-d-learn mailing list