[Issue 17129] New: class-nested alias of free function can't be called from const-methods
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Jan 30 06:16:38 PST 2017
https://issues.dlang.org/show_bug.cgi?id=17129
Issue ID: 17129
Summary: class-nested alias of free function can't be called
from const-methods
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: dlang at supradigital.org
The following code fails with this compiler message:
main.d(11): Error: template main.C.filter!((a) => a != 0).filter cannot deduce
function from argument types !()(int[]) const, candidates are:
/usr/include/dmd/phobos/std/algorithm/iteration.d(1057):
main.C.filter!((a) => a != 0).filter(Range)(Range range) if
(isInputRange!(Unqual!Range))
import std.algorithm;
alias filterZeros2 = filter!(a=>a!=0);
class C
{
alias filterZeros = filter!(a=>a!=0);
void doCount ( ) const
{
filterZeros([1,2,3]).count; // fails
filterZeros2([1,2,3]).count; // works
}
void doCount ( )
{
filterZeros([1,2,3]).count; // works
filterZeros2([1,2,3]).count; // works
}
}
void main() {}
--
More information about the Digitalmars-d-bugs
mailing list