Alias Quirks
Swiss army knife for getting information about things.
alias Quirks(alias thing_)
= value;
Takes thing and tries to apply a list of functions and templates to it. All that compile can be accessed using property syntax on the resulting alias.
The code for this is generated during compile-time using traits and mixins. Below is a list of properties that are possible to access (note not all will be available for every instantiation):
- attributes
- fields -> see
Fields
- functionAttributes -> see
FunctionAttributes
- isAggregate -> see
isAggregate
- isArray -> see
isArray
- isAssociativeArray -> see
isAssociativeArray
- isBasic -> see
isBasic
- isModule -> see
isModule
- isNested
- isNumeric -> see
isNumeric
- isSomeString -> see
isSomeString
- isStatic -> see
isStatic
- memberNames -> see
MemberNames
- members -> see
Members
- methods -> see
Methods
- name
- parameters -> see
Parameters
- qualifiedName
- returnType
- simpleType -> see
SimpleTypeOf
- type
In addition, the following properties that require a template parameter are also available:
- fieldsFilter(alias predicate) -> returns the fields property filtered with the given predicate
- getUDAs(alias uda) -> returns the same as getUDAs from std.traits
- getUDA(alias uda) -> returns the first result returned by getUDAs
- hasField(alias predicate) -> see
hasField
- hasMember(alias predicate) -> see
hasMember
- hasMethod(alias predicate) -> see
hasMethod
- hasUDA(alias uda) -> return the same as hasUDA from std.traits
- isInstanceOf(alias templ) -> see
isInstanceOf
- membersFilter(alias predicate) -> returns the members property filtered with the given predicate
- methodsFilter(alias predicate) -> returns the methods property filtered with the given predicate
Example
struct S {
static long id;
int age;
static string name() {
return "name";
}
void update(bool force) { }
}
Quirks!S .type; // S
Quirks!S .fields .length; // 2
Quirks!S .methods[1] .name; //update
Quirks!S .isArray; // false
Quirks!S .methods[1] .parameters[0] .type; // bool