[Issue 5469] New: Limitation when instantiating templates in the context of a function
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jan 20 12:29:09 PST 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5469
Summary: Limitation when instantiating templates in the context
of a function
Product: D
Version: D2
Platform: x86_64
OS/Version: Linux
Status: NEW
Severity: enhancement
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: jens.k.mueller at gmx.de
--- Comment #0 from jens.k.mueller at gmx.de 2011-01-20 12:27:09 PST ---
The following code does not compile (tried with dmd v2.050 on Linux).
import std.functional;
import std.algorithm;
void main() {
auto numbers = [0, 1, 2, 3, 4, 5];
bool var = true;
bool returnVar(uint a) { return var; }
alias not!(returnVar) notReturnVar;
//bool notReturnVar(uint a) { return not!returnVar(a); } // workaround
filter!(returnVar)(numbers);
filter!(notReturnVar)(numbers); // does not compile
}
It fails with:
/path/to/src/phobos/std/algorithm.d(854): Error: constructor
std.algorithm.Filter!(not,int[]).Filter.this cannot get frame pointer to not
/path/to/src/phobos/std/algorithm.d(866): Error: function
std.algorithm.Filter!(not,int[]).Filter.popFront cannot get frame pointer to
not
It has problems getting the frame pointer to the template function
not!(returnVar). As far as I understand it.
A workaround is to define a non-template function.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list