findNextUDA

Small convenience wrapper to find and extract certain UDA from given type. Will start at the given index and stop on the next element which is of required type.

  1. template findNextUDA(alias UDA, alias Symbol, long idx, bool allow_types = false)
  2. template findNextUDA(UDA, alias Symbol, long idx, bool allow_types = false)

Members

Manifest constants

findNextUDA
enum findNextUDA;
Undocumented in source.

Templates

extract
template extract(size_t index, list...)
Undocumented in source.

Parameters

UDA

type or template to search for in UDA list

Symbol

symbol to query for UDA's

idx

0-based index to start at. Should be positive, and under the total number of attributes.

allow_types

if set to false considers attached UDA types an error (only accepts instances/values)

Return Value

aggregated search result struct with 3 field. value aliases found UDA. found is boolean flag for having a valid find. index is integer index in attribute list this UDA was found at.

Examples

struct Attribute { int x; }

@("something", Attribute(42), Attribute(41))
void symbol();

enum result0 = findNextUDA!(string, symbol, 0);
static assert (result0.found);
static assert (result0.index == 0);
static assert (result0.value == "something");

enum result1 = findNextUDA!(Attribute, symbol, 0);
static assert (result1.found);
static assert (result1.index == 1);
static assert (result1.value == Attribute(42));

enum result2 = findNextUDA!(int, symbol, 0);
static assert (!result2.found);

enum result3 = findNextUDA!(Attribute, symbol, result1.index + 1);
static assert (result3.found);
static assert (result3.index == 2);
static assert (result3.value == Attribute(41));

Meta