hasUnsharedAliasing

Returns true if and only if T's representation includes at least one of the following:

  1. a raw pointer U* and U is not immutable or shared;
  2. an array U[] and U is not immutable or shared;
  3. a reference to a class type C and C is not immutable or shared.
  4. an associative array that is not immutable or shared.
  5. a delegate that is not shared.
template hasUnsharedAliasing (
T...
) {
enum hasUnsharedAliasing;
}

Examples

1 struct S1 { int a; Object b; }
2 struct S2 { string a; }
3 struct S3 { int a; immutable Object b; }
4 static assert( hasUnsharedAliasing!S1);
5 static assert(!hasUnsharedAliasing!S2);
6 static assert(!hasUnsharedAliasing!S3);
7 
8 struct S4 { int a; shared Object b; }
9 struct S5 { char[] a; }
10 struct S6 { shared char[] b; }
11 struct S7 { float[3] vals; }
12 static assert(!hasUnsharedAliasing!S4);
13 static assert( hasUnsharedAliasing!S5);
14 static assert(!hasUnsharedAliasing!S6);
15 static assert(!hasUnsharedAliasing!S7);

Meta

Suggestion Box / Bug Report