[Issue 18732] Can use template as type in a templatized class

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Apr 6 20:43:21 UTC 2018


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

ag0aep6g <ag0aep6g at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |ag0aep6g at gmail.com
         Resolution|---                         |INVALID

--- Comment #1 from ag0aep6g <ag0aep6g at gmail.com> ---
Working as intended.

    class Foo(bool b) { .... }

is equivalent to

    template Foo(bool b)
    {
        class Foo { ... }
    }

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

Inside the class, the name "Foo" refers to the class itself. To refer to the
template, you have to use `.Foo`. However, you can use `Foo!false`, because the
compiler is being nice. I don't know if that's in the spec, or if it's just a
welcome quirk.

Closing as invalid. Feel free to reopen if I'm missing something here.

--


More information about the Digitalmars-d-bugs mailing list