Hi,
following code throws an error when I uncomment method
getPropertyDuplicate.
getPropertyDuplicate is just a copy of getProperty except the
method name.
Why these errors are thrown?
C:\D\dmd2\windows\bin\..\..\src\phobos\std\traits.d(1257): Error:
isCallable!(ge
tPropertyDuplicate) is not an expression
source\app.d(25): while looking for match for
functionAttributes!(getProp
ertyDuplicate)
C:\D\dmd2\windows\bin\..\..\src\phobos\std\traits.d(1257): Error:
template insta
nce std.traits.isCallable!(getPropertyDuplicate) error
instantiating
source\app.d(11): instantiated from here:
functionAttributes!(getProperty
Duplicate)
source\app.d(11): while looking for match for
functionAttributes!(getProp
ertyDuplicate)
Kind regards
André
template MyTemplate()
{
import std.traits : isSomeFunction, functionAttributes,
FunctionAttribute, ReturnType;
string[] getPropertyNames()
{
string[] result;
foreach(m;__traits(allMembers, typeof(this)))
{
static if (isSomeFunction!(__traits(getMember, typeof(this),
m))
&& functionAttributes!(__traits(getMember, typeof(this), m))
& FunctionAttribute.property)
{
result ~= m;
}
}
return result;
}
/*string[] getPropertyDuplicate()
{
string[] result;
foreach(m;__traits(allMembers, typeof(this)))
{
static if (isSomeFunction!(__traits(getMember, typeof(this),
m))
&& functionAttributes!(__traits(getMember, typeof(this), m))
& FunctionAttribute.property)
{
result ~= m;
}
}
return result;
}*/
}
class A {
mixin MyTemplate;
}
void main() {
auto a = new A();
}