hasField

Returns true if a field can be found on aggregate filtered with the given predicate, false otherwise.

  1. auto hasField()
  2. auto hasField()
    @safe pure nothrow
    hasField
    (
    alias aggregate
    alias predicate
    )
    ()
    if (
    (
    isAggregate!aggregate ||
    isModule!aggregate
    )
    &&
    is(typeof(unaryFun!predicate))
    )

Examples

struct S {
    long id;
    int age;
    string name() {
        return "name";
    }
}

hasField!(S, field => isNumeric!(field.type)); // returns true
hasField!(S, field => is(field.type == string)); // returns false

Meta