| 1 |
// https://issues.dlang.org/show_bug.cgi?id=22859 |
| 2 |
private struct __InoutWorkaroundStruct {} |
| 3 |
@property T rvalueOf(T)(T val) { return val; } |
| 4 |
@property T rvalueOf(T)(inout __InoutWorkaroundStruct = __InoutWorkaroundStruct.init); |
| 5 |
@property ref T lvalueOf(T)(inout __InoutWorkaroundStruct = __InoutWorkaroundStruct.init); |
| 6 |
|
| 7 |
// taken from std.traits.isAssignable |
| 8 |
template isAssignable(Lhs, Rhs = Lhs) |
| 9 |
{ |
| 10 |
enum isAssignable = __traits(compiles, lvalueOf!Lhs = rvalueOf!Rhs) && __traits(compiles, lvalueOf!Lhs = lvalueOf!Rhs); |
| 11 |
} |
| 12 |
|
| 13 |
// taken from std.meta.allSatisfy |
| 14 |
template allSatisfy(alias F, T...) |
| 15 |
{ |
| 16 |
static foreach (Ti; T) |
| 17 |
{ |
| 18 |
static if (!is(typeof(allSatisfy) == bool) && // not yet defined |
| 19 |
!F!(Ti)) |
| 20 |
{ |
| 21 |
enum allSatisfy = false; |
| 22 |
} |
| 23 |
} |
| 24 |
static if (!is(typeof(allSatisfy) == bool)) // if not yet defined |
| 25 |
{ |
| 26 |
enum allSatisfy = true; |
| 27 |
} |
| 28 |
} |
| 29 |
|
| 30 |
struct None{} |
| 31 |
|
| 32 |
class C1 |
| 33 |
{ |
| 34 |
static if(allSatisfy!(isAssignable, None, C2)) {} |
| 35 |
} |
| 36 |
|
| 37 |
class C2 |
| 38 |
{ |
| 39 |
static if(allSatisfy!(isAssignable, None, C1, C2)) {} |
| 40 |
} |