Templated Enums?

Era Scarecrow rtcvb32 at yahoo.com
Wed Jun 6 12:40:00 PDT 2012


On Wednesday, 6 June 2012 at 19:27:25 UTC, Johannes Pfau wrote:
> Am Wed, 06 Jun 2012 21:01:21 +0200
> schrieb "Era Scarecrow" <rtcvb32 at yahoo.com>:
> According to http://dlang.org/template.html
> something like this:
> ---------------
> class Bar(T) { T member; }
> ---------------
>
> is actually only syntactic sugar for this:
> ---------------
> template Bar(T) { class Bar { T member; } }
> ---------------
>
> So instead of
> ---------------
> enum(T) X
> {
>      bitsPerT = T.sizeof * 8,
> }
> ---------------
>
> it should be possible to do this:
> ---------------
> template X(T)
> {
>     enum X
>     {
>         bitsPerT = T.sizeof * 8,
>     }
> }
> ---------------

  Interesting... I was wondering that as well, however I don't 
fully understand templates; those and tuples. I'm sure I'll grok 
it all eventually.


More information about the Digitalmars-d-learn mailing list