diff options
Diffstat (limited to 'libphobos/src/std/algorithm')
-rw-r--r-- | libphobos/src/std/algorithm/mutation.d | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/libphobos/src/std/algorithm/mutation.d b/libphobos/src/std/algorithm/mutation.d index 22b7b98..b0e7707 100644 --- a/libphobos/src/std/algorithm/mutation.d +++ b/libphobos/src/std/algorithm/mutation.d @@ -866,6 +866,9 @@ if (isInputRange!InputRange Initializes all elements of `range` with their `.init` value. Assumes that the elements of the range are uninitialized. +This function is unavailable if `T` is a `struct` and `T.this()` is annotated +with `@disable`. + Params: range = An $(REF_ALTTEXT input range, isInputRange, std,range,primitives) @@ -874,10 +877,11 @@ Params: See_Also: $(LREF fill) - $(LREF uninitializeFill) + $(LREF uninitializedFill) */ void initializeAll(Range)(Range range) -if (isInputRange!Range && hasLvalueElements!Range && hasAssignableElements!Range) +if (isInputRange!Range && hasLvalueElements!Range && hasAssignableElements!Range + && __traits(compiles, { static ElementType!Range _; })) { import core.stdc.string : memset, memcpy; import std.traits : hasElaborateAssign, isDynamicArray; @@ -1037,6 +1041,18 @@ if (is(Range == char[]) || is(Range == wchar[])) assert(xs[1].x == 3); } +// https://issues.dlang.org/show_bug.cgi?id=22105 +@system unittest +{ + struct NoDefaultCtor + { + @disable this(); + } + + NoDefaultCtor[1] array = void; + static assert(!__traits(compiles, array[].initializeAll)); +} + // move /** Moves `source` into `target`, via a destructive copy when necessary. |