Hi, Does anyone know how to detect if there is a setter for a property? The code below prints the same thing for both the setter and the getter of "front":
==============================
import std.traits;
class Foo {
uint num;
@property ref uint front() {
return num;
}
@property void front(uint i) {
num = i;
}
ref uint front2() {
return num;
}
}
template isProperty(alias func) if (isCallable!(func)) {
enum isProperty = (functionAttributes!(func) &
FunctionAttribute.PROPERTY)==0 ? false : true;
}
template hasSetter(alias func) if (isCallable!(func)) {
enum hasSetter = (isProperty!(func) && ParameterTypeTuple!(func).length
>
0 && ReturnType!(func).stringof != "void") ? true : false;
}
void main() {
Foo foo;
pragma(msg, hasSetter!(foo.front));
static if (isProperty!(foo.front)) {
pragma(msg, "property");
} else {
pragma(msg, "not a property");
}
alias MemberFunctionsTuple!(Foo,"front") fronts;
foreach (s; fronts) {
pragma(msg, ReturnType!(s)); // this line just prints "uint"
for both
"front" properties!
}
}
============================
Is this a compiler bug? Or am I wrong again?
Thanks
Rory
www.neonova.co.za: http://cf.neonova.co.za/9YXp
View: https://mail1.clearformat.com/vcard.php?uid=11&pid=10
Beta Test Advert: http://fwd.clearformat.com/9YXn
<<inline: logo.jpg>>
<<inline: ff2d54b.jpg>>
