Using attributes inside template instantiation

Uranuz via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jun 25 08:54:42 PDT 2014


I'm trying to declare format for database record in compile time. 
I consider to use attributes fo this. Can I do something similar 
to this code?

struct RecordFormat(T)
{}

alias Format = RecordFormat!( @("cool") int );

pragma( msg, Format );
	
void main()
{
}

Or I want something strange that is not supported by language? 
For now I don't understand whether UDA are a part of types or 
they are a part of variable instance definition or something 
different (3rd dimension)).

For example 'const int' is a type but what @attribute int is? Can 
it be considered as separate type or it could be binded to 
definition of variable only?
@attribute int number;

I failed to alias type
alias coolInt = @("cool") int;

But I can alias const int
alias constInt = const int;

I think I understood something wrong about attributes.


More information about the Digitalmars-d-learn mailing list