D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4408 - Ambiguity when using std.algorithm.splitter with generic ranges
Summary: Ambiguity when using std.algorithm.splitter with generic ranges
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: Andrei Alexandrescu
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-29 19:11 UTC by David Simcha
Modified: 2010-08-16 19:57 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description David Simcha 2010-06-29 19:11:19 UTC
import std.algorithm;

struct Range {
    int[] nums = [1,2,3,4,5,6,7,8,9,10];

    @property int front() {
        return nums[0];
    }

    void popFront() {
        nums = nums[1..$];
    }

    @property bool empty() {
        return nums.length == 0;
    }

    @property typeof(this) save() {
        return this;
    }
}

void main() {
    Range r;
    auto split = splitter(r, 5);
}

d:\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(845): Error: template instance Splitter!(Range,int) matches more than one template declaration, d:\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(790):Splitter(Range,Separator) if (is(typeof(ElementType!(Range).init == Separator.init))) and d:\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(1044):Splitter(alias isTerminator,Range,Slice = Select!(is(typeof(Range.init[0..1])),Range,ElementType!(Range)[]))
d:\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(846): Error: Splitter!(Range,int) is used as a type
d:\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(852): Error: function expected before (), not void of type void
d:\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(25): Error: template instance std.algorithm.splitter!(Range,int) error instantiating
test9.d(25): Error: variable test9.main.split voids have no value
test9.d(25): Error: expression splitter(r,5) is void and has no value
Comment 1 David Simcha 2010-08-16 19:57:13 UTC
Fixed SVN.