@@ -114,7 +114,7 @@ enum hasToHash(T) = __traits(hasMember, T, "toHash");
114
114
static if (__VERSION__ < 2094 )
115
115
enum isCopyable (S) = is (typeof ({ S foo = S.init; S copy = foo; }));
116
116
else
117
- enum isCopyable (S) = __traits(isCopyable, S);
117
+ enum isCopyable (S) = __traits(isCopyable, S);
118
118
enum isPOD (T) = __traits(isPOD, T);
119
119
enum Sizeof (T) = T.sizeof;
120
120
@@ -136,20 +136,14 @@ enum hasSemiMutableConstruction(T) = __traits(compiles, {static struct S { T a;
136
136
static assert (hasInoutConstruction! S);
137
137
}
138
138
139
- template staticIsSorted (alias cmp, Seq... )
140
- {
141
- static if (Seq.length <= 1 )
142
- enum staticIsSorted = true ;
143
- else static if (Seq.length == 2 )
144
- enum staticIsSorted = cmp! (Seq[0 ], Seq[1 ]);
145
- else
139
+ enum staticIsSorted (alias cmp, items... ) =
146
140
{
147
- enum staticIsSorted =
148
- cmp ! (Seq[($ / 2 ) - 1 ], Seq[$ / 2 ]) &&
149
- staticIsSorted ! (cmp, Seq[ 0 .. $ / 2 ]) &&
150
- staticIsSorted ! (cmp, Seq[$ / 2 .. $]) ;
151
- }
152
- }
141
+ static if (items.length > 1 )
142
+ static foreach (i, item; items[ 1 .. $])
143
+ static if (cmp ! (items[i], item))
144
+ if (__ctfe) return false ;
145
+ return true ;
146
+ }();
153
147
154
148
template TryRemoveConst (T)
155
149
{
0 commit comments