[Issue 13571] New: Overload of std.range.tee which accepts a functions does not accept structs or classes with opCall
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Fri Oct 3 22:59:11 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=13571
Issue ID: 13571
Summary: Overload of std.range.tee which accepts a functions
does not accept structs or classes with opCall
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: monkeyworks12 at hotmail.com
The following code does not work currently with tee:
struct Callable
{
void opCall(int n)
{
writeln(n);
}
}
void main()
{
auto ints = [1, 2, 3];
//Error
auto res = ints.tee!Callable;
}
Note that the following code *does* work:
struct Callable
{
void opCall(int n)
{
writeln(n);
}
}
void main()
{
Callable callable;
auto ints = [1, 2, 3];
auto r = ints.tee(callable);
foreach (_; r) {} //Prints 1 2 3
}
So I don't know how useful adding support for doing `tee!Callable` would be.
--
More information about the Digitalmars-d-bugs
mailing list