Idiomatic way to check for UDA?

ketmar via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jun 6 23:20:55 PDT 2015


On Sun, 07 Jun 2015 05:32:46 +0000, Tofu Ninja wrote:

> Whats the idiomatic way to check if an identifier has a specific UDA
> attached to it.
> 
> Also what should I use to define a UDA that doesn't need to carry any
> data? Just an empty template? Or does something else make more sense?

there is `std.traits.hasUDA` added to phobos recently. but until official 
release you have to write your own `hasUDA`. alas.

as for defining UDA without data, you can use this trick:

  enum MyUDA;
  @MyUDA int i;

as it doesn't really need to be semantically analyzed, this forward 
declaration can work just fine.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20150607/e48e7380/attachment.sig>


More information about the Digitalmars-d-learn mailing list