View source code
							
							
						
								Display the source code in std/traits.d from which this
								page was generated on github.
							
						
							Report a bug
							
						
								If you spot a problem with this page, click here to create a
								Bugzilla issue.
							
						
							
								Improve this page
							
							
					
								Quickly fork, edit online, and submit a pull request for this page.
								Requires a signed-in GitHub account. This works well for small changes.
								If you'd like to make larger changes you may want to consider using
								local clone.
							
						Alias std.traits.getSymbolsByUDA
				
						
					
				Parameters
| Name | Description | 
|---|---|
| symbol | The aggregate type or module to search | 
| attribute | The user-defined attribute to search for | 
Returns
All symbols within symbol that have the given UDA attribute.
Note
This is not recursive; it will not search for symbols within symbols such as nested structs or unions.
Example
enum Attr;
struct A
{
    @Attr int a;
    int b;
}
static assert(getSymbolsByUDA!(A, Attr)Example
enum Attr;
static struct A
{
    @Attr int a;
    int b;
    @Attr void doStuff() {}
    void doOtherStuff() {}
    static struct Inner
    {
        // Not found by getSymbolsByUDA
        @Attr int c;
    }
}
// Finds both variables and functions with the attribute, but
// doesn't include the variables and functions without it.
static assert(getSymbolsByUDA!(A, Attr)Example
Finds multiple attributes
static struct UDA { string name; }
static struct B
{
    @UDA("X")
    int x;
    @UDA("Y")
    int y;
    @(100)
    int z;
}
// Finds both UDA attributes.
static assert(getSymbolsByUDA!(B, UDA)Example
Checks for UDAs on the aggregate symbol itself
static struct UDA { string name; }
@UDA("A")
static struct C
{
    @UDA("B")
    int d;
}
static assert(getSymbolsByUDA!(C, UDA)Example
Finds nothing if there is no member with specific UDA
static struct UDA { string name; }
static struct D
{
    int x;
}
static assert(getSymbolsByUDA!(D, UDA)Authors
Walter Bright,
            Tomasz Stachowiak (isExpressions),
            Andrei Alexandrescu,
            Shin Fujishiro,
            Robert Clipsham,
            David Nadlinger,
            Kenji Hara,
            Shoichi Kato
License
					Copyright © 1999-2024 by the D Language Foundation | Page generated by ddox.