container: array: add type checks for passed arguments in insertAfter()

insertAfter should receive a valid element or a Range of values according to
type T of the corresponding instance Array!T.

Signed-off-by: Luís Ferreira <contact@lsferreira.net>
This commit is contained in:
Luís Ferreira 2021-01-18 01:08:13 +00:00 committed by The Dlang Bot
parent 14b1c86f10
commit ce558d26b1

View file

@ -1008,6 +1008,8 @@ if (!is(immutable T == immutable bool))
/// ditto
size_t insertAfter(Stuff)(Range r, Stuff stuff)
if (isImplicitlyConvertible!(Stuff, T) ||
isInputRange!Stuff && isImplicitlyConvertible!(ElementType!Stuff, T))
{
import std.algorithm.mutation : bringToFront;
enforce(r._outer._data is _data);
@ -2199,6 +2201,8 @@ if (is(immutable T == immutable bool))
/// ditto
size_t insertAfter(Stuff)(Range r, Stuff stuff)
if (isImplicitlyConvertible!(Stuff, T) ||
isInputRange!Stuff && isImplicitlyConvertible!(ElementType!Stuff, T))
{
import std.algorithm.mutation : bringToFront;
// TODO: make this faster, it moves one bit at a time