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

--- Comment #0 from 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!(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

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:
------- You are receiving this mail because: -------

Reply via email to