www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18525] New: Constraint on std.algorithm.mutation.remove fails

https://issues.dlang.org/show_bug.cgi?id=18525

          Issue ID: 18525
           Summary: Constraint on std.algorithm.mutation.remove fails with
                    char[]
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Mac OS X
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: flyboynw gmail.com

Consider the following code:

void main()
{
    import std.algorithm.mutation;
    import std.stdio: write, writeln, writef, writefln;
    import std.typecons : tuple;

    int[] ints;
    char[] chars;

    ints = [ 1, 2, 3, 4, 5, 6, 7, 8 ];
    writeln(remove(ints, tuple(1, 4)));

    chars = [ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' ];
    writeln(remove(chars, 1));

    chars = [ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' ];
    writeln(remove(chars, tuple(1, 4)));
}

While the ints example works, the chars examples fail to compile with the
following error output: 

onlineapp.d(14): Error: template std.algorithm.mutation.remove cannot deduce
function from argument types !()(char[], int), candidates are:
/dlang/dmd-beta/linux/bin64/../../src/phobos/std/algorithm/mutation.d(1792):   
    std.algorithm.mutation.remove(SwapStrategy s = SwapStrategy.stable, Range,
Offset...)(Range range, Offset offset) if (s != SwapStrategy.stable &&
isBidirectionalRange!Range && hasLvalueElements!Range && hasLength!Range &&
(Offset.length >= 1))
/dlang/dmd-beta/linux/bin64/../../src/phobos/std/algorithm/mutation.d(1879):   
    std.algorithm.mutation.remove(SwapStrategy s = SwapStrategy.stable, Range,
Offset...)(Range range, Offset offset) if (s == SwapStrategy.stable &&
isBidirectionalRange!Range && hasLvalueElements!Range && (Offset.length >= 1))
/dlang/dmd-beta/linux/bin64/../../src/phobos/std/algorithm/mutation.d(2034):   
    std.algorithm.mutation.remove(alias pred, SwapStrategy s =
SwapStrategy.stable, Range)(Range range) if (isBidirectionalRange!Range &&
hasLvalueElements!Range)
onlineapp.d(17): Error: template std.algorithm.mutation.remove cannot deduce
function from argument types !()(char[], Tuple!(int, int)), candidates are:
/dlang/dmd-beta/linux/bin64/../../src/phobos/std/algorithm/mutation.d(1792):   
    std.algorithm.mutation.remove(SwapStrategy s = SwapStrategy.stable, Range,
Offset...)(Range range, Offset offset) if (s != SwapStrategy.stable &&
isBidirectionalRange!Range && hasLvalueElements!Range && hasLength!Range &&
(Offset.length >= 1))
/dlang/dmd-beta/linux/bin64/../../src/phobos/std/algorithm/mutation.d(1879):   
    std.algorithm.mutation.remove(SwapStrategy s = SwapStrategy.stable, Range,
Offset...)(Range range, Offset offset) if (s == SwapStrategy.stable &&
isBidirectionalRange!Range && hasLvalueElements!Range && (Offset.length >= 1))
/dlang/dmd-beta/linux/bin64/../../src/phobos/std/algorithm/mutation.d(2034):   
    std.algorithm.mutation.remove(alias pred, SwapStrategy s =
SwapStrategy.stable, Range)(Range range) if (isBidirectionalRange!Range &&
hasLvalueElements!Range)

Note: strings are confirmed to work.

--
Feb 26 2018