如何在 D 中限制用户定义的属性应用程序?

How can I restrict user defined attribute application in D?

我想使用户定义的属性仅可附加到 struct/class 方法。在Java的注解中有这样的选项:@Target restricts annotation attach targets。 D有模拟吗?

不,但是你可以让你编写的处理器处理它 static assert(0) 如果它发现它附加到一个。