Example
struct A { bool method1(string a); bool method1(float b); string method1(); string field; } static assert(hasOverload!(A, bool function(string), "method1")); static assert(hasOverload!(A, bool function(float), "method1")); static assert(hasOverload!(A, string function(), "method1")); static assert(hasOverload!(A, string, "field")); static assert(!hasOverload!(A, bool, "field")); static assert(!hasOverload!(A, void function(), "method1")); static assert(!hasOverload!(A, bool function(), "method1")); static assert(!hasOverload!(A, string function(float), "method1")); /// TODO: at next realease check overloads by attributes // struct D // { // string toString() const {return "";} // } // // static assert(hasOverload!(D, const string function(), "toString")); // static assert(!hasOverload!(D, string function(), "toString"));
Variant of std.traits.hasMember that checks also by member type to handle overloads.
T is a type to be checked. ElemType is a member type, and ElemName is a member name. Template returns true if T has element (field or method) of type ElemType with name ElemName.
Template returns false for non aggregates.