Skip to content

Calling splitter with both a predicate and a string for the separator matches two overloads #10760

Open
@jmdavis

Description

@jmdavis

This code fails to compile

void main()
{
    import std.algorithm.iteration : splitter;
    import std.algorithm.searching : canFind;
    import std.typecons : Yes;

    auto range = "16x16+0-2".splitter!((a, b) => "x+-".canFind(a), Yes.keepSeparators)("x");
}

giving

q.d(7): Error: `std.algorithm.iteration.splitter` called with argument types `(string, string)` matches multiple overloads exactly:
/usr/local/include/dmd/std/algorithm/iteration.d(5338):     `std.algorithm.iteration.splitter!((a, b) => "x+-".canFind(a), Flag.yes, string, string).splitter(string r, string s)`
and:
/usr/local/include/dmd/std/algorithm/iteration.d(5909):     `std.algorithm.iteration.splitter!((a, b) => "x+-".canFind(a), Flag.yes, string, string).splitter(string r, string s)`
auto range = "16x16+0-2".splitter!((a, b) => "x+-".canFind(a), Yes.keepSeparators)("x");
^

This is contrast to

void main()
{
    import std.algorithm.iteration : splitter;
    import std.algorithm.searching : canFind;
    import std.typecons : Yes;

    auto range = "16x16+0-2".splitter!((a, b) => "x+-".canFind(a), Yes.keepSeparators)('x');
}

which compiles just fine (though is buggy with front as shown in #10759).

So, the template constraints need work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions