hasOverload

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.

Members

Aliases

overloads
alias overloads = staticMap!(extractType, __traits(getOverloads, T, ElemName))
Undocumented in source.
overloads
alias overloads = ExpressionList!()
Undocumented in source.
paramExpressionList
alias paramExpressionList = ParameterTypeTuple!ElemType
Undocumented in source.
retType
alias retType = ReturnType!ElemType
Undocumented in source.

Manifest constants

hasOverload
enum hasOverload;
Undocumented in source.
hasOverload
enum hasOverload;
Undocumented in source.
hasOverload
enum hasOverload;
Undocumented in source.

Examples

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"));

Meta