D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6935 - struct with @disable this cannot make range
Summary: struct with @disable this cannot make range
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: patch, rejects-valid
Depends on:
Blocks:
 
Reported: 2011-11-12 01:11 UTC by Kenji Hara
Modified: 2014-02-14 23:21 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Kenji Hara 2011-11-12 01:11:57 UTC
Following code should compile, but doesn't.

import std.range;
struct R
{
    @disable this();  // requires explicit initializer

    @property bool empty() const{ return false; }
    @property int front(){ return 0; }
    void popFront(){}

    @property R save(){ return this; }

    int back(){ return 0; }
    void popBack(){}

    int opIndex(size_t n){ return 0; }
    @property size_t length() const { return 0; }
}
static assert(isInputRange!R);
static assert(isForwardRange!R);
static assert(isBidirectionalRange!R);
static assert(isRandomAccessRange!R);
Comment 3 github-bugzilla 2014-02-14 23:21:25 UTC
Commit pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/6f43a92cd2ed4b16e2dbf8cc6550396f82180b99
Fix predicate template implementations in std.traits and std.range

Use T.init property instead of void initializer, because it will work even if T is const or immutable type.

I must change a part of unit test for the bug 6935, because we cannot support ranges which overrides init property.