Summary: Allow passing arguments to templates in CTFE
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD

--- Comment #0 from 2012-09-23 13:47:19 PDT ---
When doing CTFE it may be worthwhile to allow passing of function arguments to
template instantiations. This eases better integration between templates and
CTFE making meta programming more convenient.

bool foo(string a)                                                              
    return bar!(a);                                                             

template bar(string b)                                                          
    enum bar = true;                                                            

fails to compile with
test.d(3): Error: variable a cannot be read at compile time

The problem is that foo must be compilable to be executed at run-time which
clearly cannot work with the above code. But if __ctfe was a compile-time known
value foo could be written like:
static if (__ctfe)
    return bar!(a)
    return false;

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to