propertySemantics

Tells you if a name is a read and/or write property

propertySemantics
(
T
string name
)
()
if ()

Return Value

Type: auto

Tuple!(bool, "isRead", bool, "isWrite")

Examples

1 import std.typecons;
2 
3 struct S
4 {
5     int m;
6     @property int rp()
7     {
8         return m;
9     }
10 
11     @property void wp(int)
12     {
13     }
14 
15     @property int rwp()
16     {
17         return m;
18     }
19 
20     @property void rwp(int)
21     {
22     }
23 }
24 
25 static assert(!__traits(compiles, propertySemantics!(S, "na")));
26 static assert(!__traits(compiles, propertySemantics!(S, "m")));
27 
28 static assert(propertySemantics!(S, "rp") == tuple!("canRead", "canWrite")(true, false));
29 static assert(propertySemantics!(S, "wp") == tuple!("canRead", "canWrite")(false, true));
30 static assert(propertySemantics!(S, "rwp") == tuple!("canRead", "canWrite")(true, true));

Meta