hasMethod - multiple declarations
Function hasMethod
Returns true if a method can be found on aggregate with the given methodName, false otherwise.
auto hasMethod(alias aggregate, string methodName)() pure nothrow @safe
if (isAggregate!aggregate || isModule!aggregate);
Example
struct S {
long id;
int age;
string name() {
return "name";
}
}
hasField!(TestStruct, "name"); // returns true
hasField!(TestStruct, "age"); // returns false
Function hasMethod
Returns true if a method can be found on aggregate filtered with the given predicate, false otherwise.
auto hasMethod(alias aggregate, alias predicate)() pure nothrow @safe
if (isAggregate!aggregate || isModule!aggregate);
Example
struct S {
long id;
int age;
string name() {
return "name";
}
}
hasField!(TestStruct, method => method .name == "name"); // returns true
hasField!(TestStruct, method => is(method .returnType == int)); // returns false