View source code Display the source code in std/traits.d from which this page was generated on github. 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. Page wiki View or edit the community-maintained wiki page associated with this page.

Template std.traits.RepresentationTypeTuple

Get the primitive types of the fields of a struct or class, in topological order.

Arguments

template RepresentationTypeTuple(T);

Example

struct S1 { int a; float b; }
struct S2 { char[] a; union { S1 b; S1 * c; } }
alias R = RepresentationTypeTuple!S2;
assert(R.length == 4
    && is(R[0] == char[]) && is(R[1] == int)
    && is(R[2] == float) && is(R[3] == S1*));

Example

// simple types
static assert(!hasRawAliasing!int);
static assert( hasRawAliasing!(char*));
// references aren't raw pointers
static assert(!hasRawAliasing!Object);
// built-in arrays do contain raw pointers
static assert( hasRawAliasing!(int[]));
// aggregate of simple types
struct S1 { int a; double b; }
static assert(!hasRawAliasing!S1);
// indirect aggregation
struct S2 { S1 a; double b; }
static assert(!hasRawAliasing!S2);

Example

// simple types
static assert(!hasRawUnsharedAliasing!int);
static assert( hasRawUnsharedAliasing!(char*));
static assert(!hasRawUnsharedAliasing!(shared char*));
// references aren't raw pointers
static assert(!hasRawUnsharedAliasing!Object);
// built-in arrays do contain raw pointers
static assert( hasRawUnsharedAliasing!(int[]));
static assert(!hasRawUnsharedAliasing!(shared int[]));
// aggregate of simple types
struct S1 { int a; double b; }
static assert(!hasRawUnsharedAliasing!S1);
// indirect aggregation
struct S2 { S1 a; double b; }
static assert(!hasRawUnsharedAliasing!S2);
// struct with a pointer member
struct S3 { int a; double * b; }
static assert( hasRawUnsharedAliasing!S3);
struct S4 { int a; shared double * b; }
static assert(!hasRawUnsharedAliasing!S4);

Authors

Walter Bright, Tomasz Stachowiak (isExpressions), Andrei Alexandrescu, Shin Fujishiro, Robert Clipsham, David Nadlinger, Kenji Hara, Shoichi Kato

License

Boost License 1.0.

Comments