On Monday, 23 September 2013 at 07:47:32 UTC, Jacob Carlborg wrote:
On 2013-09-20 16:12, simendsjo wrote:

You could of course fix this in a library too.

enum AttributeUsage {
  struct_ = 1 << 0,
  class_ = 1 << 1,
  //etc
}

struct attribute { AttributeUsage usage; }

Then the library could give a compile-time error if you tries to use it
where it's not meant to be.

I'm not sure how I could do that.

You can recurse into UDAs for attributes and pass along the type that had the uda. A static assert could verify that it's used on the correct type. (For my library, that would mean editing my getMembersAndAttributes template.)

Reply via email to