digitalmars.D.bugs - [Issue 4305] New: Take, Chain on top of ranges w/o moveFront()
- d-bugmail puremagic.com (52/52) Jun 13 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4305
- d-bugmail puremagic.com (16/16) Jun 13 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4305
- d-bugmail puremagic.com (8/8) Jun 13 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4305
- d-bugmail puremagic.com (11/11) Jun 24 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4305
http://d.puremagic.com/issues/show_bug.cgi?id=4305
Summary: Take, Chain on top of ranges w/o moveFront()
Product: D
Version: D2
Platform: Other
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: Phobos
AssignedTo: nobody puremagic.com
ReportedBy: dsimcha yahoo.com
import std.range;
struct CountRange {
uint num;
uint front() {
return num;
}
void popFront() {
num++;
}
bool empty() property {
return num == uint.max;
}
typeof(this) save() property {
return this;
}
}
void main() {
CountRange cr;
auto t = take(cr, 100);
}
This produces a compile time error:
d:\dmd2\windows\bin\..\..\src\phobos\std\range.d(1289): Error: template
std.range.moveFront(R) if (is(typeof(&r.front()) == ElementType!(R)*)) does not
match any function template declaration
d:\dmd2\windows\bin\..\..\src\phobos\std\range.d(1289): Error: template
std.range.moveFront(R) if (is(typeof(&r.front()) == ElementType!(R)*)) cannot
deduce template function from argument types !()(CountRange)
Similar results occur when the main block looks like this instead:
void main() {
CountRange cr1;
CountRange cr2;
auto c = chain(cr1, cr2);
}
I guess the correct fix is to just stick moveFront() in a static if block and
disable it for ranges that don't have lvalue elements. However, I'd like to
get some comments in case I'm misunderstanding the issue here.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 13 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4305
Andrei Alexandrescu <andrei metalanguage.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |andrei metalanguage.com
AssignedTo|nobody puremagic.com |andrei metalanguage.com
20:54:52 PDT ---
The intent is to allow manipulation of ranges that contain types arbitrarily
expensive to copy. The current design requires either front() to yield a ref,
or the range to define moveFront().
I think a better design is to define the module-level std.range.moveFront() to
issue a simple copy when the type being copied does not define this(this). I'll
do so soon. Thanks!
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 13 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4305
Andrei Alexandrescu <andrei metalanguage.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 13 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4305
David Simcha <dsimcha yahoo.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
Fixed in SVN.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 24 2010









d-bugmail puremagic.com 