Skip to content

Commit 594a9be

Browse files
authored
Merge pull request #2042 from BBasile/trait-disabled
document possible new `isDisabled` __traits
2 parents 087472b + ad7429a commit 594a9be

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

spec/traits.dd

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ $(GNAME TraitsKeyword):
3131
$(GBLINK isScalar)
3232
$(GBLINK isStaticArray)
3333
$(GBLINK isUnsigned)
34+
$(GBLINK isDisabled)
3435
$(GBLINK isVirtualFunction)
3536
$(GBLINK isVirtualMethod)
3637
$(GBLINK isAbstractFunction)
@@ -207,6 +208,31 @@ $(H2 $(GNAME isDeprecated))
207208
$(P Takes one argument. It returns `true` if the argument is a symbol
208209
marked with the `deprecated` keyword, otherwise `false`.)
209210

211+
$(H2 $(GNAME isDisabled))
212+
213+
$(P Takes one argument and returns `true` if it's a function declaration
214+
marked with `@disable`.)
215+
216+
---
217+
struct Foo
218+
{
219+
@disable void foo();
220+
void bar(){}
221+
}
222+
223+
static assert(__traits(isDisabled, Foo.foo));
224+
static assert(!__traits(isDisabled, Foo.bar));
225+
---
226+
227+
$(P For any other declaration even if `@disable` is a syntactically valid
228+
attribute `false` is returned because the annotation has no effect.)
229+
230+
---
231+
@disable struct Bar{}
232+
233+
static assert(!__traits(isDisabled, Bar));
234+
---
235+
210236
$(H2 $(GNAME isVirtualFunction))
211237

212238
$(P The same as $(GLINK isVirtualMethod), except

0 commit comments

Comments
 (0)