www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18558] New: Template alias spec incomplete

https://issues.dlang.org/show_bug.cgi?id=18558

          Issue ID: 18558
           Summary: Template alias spec incomplete
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dlang.org
          Assignee: nobody puremagic.com
          Reporter: johnnymarler gmail.com

https://dlang.org/spec/template.html#TemplateAliasParameter

[Copied from spec]
Alias parameters enable templates to be parameterized with almost any kind of D
symbol, including user-defined type names, global names, local names, module
names, template names, and template instance names. Literals can also be used
as arguments to alias parameters.


I've found that you can also pass function calls, i.e.
----------------------------
template Foo(alias x)
{
    enum Foo = x;
}
size_t return42() { return 42; }

void main()
{
    auto foo2 = Foo!(return42());
    pragma(msg, typeof(foo2).stringof);
}
----------------------------

The spec should be updated to describe the true capabilities of alias template
parameters.  It sounds like along with symbols and literals, alias parameters
can also accept compile-time values.

--
Mar 05 2018