Thread overview | ||||||
---|---|---|---|---|---|---|
|
February 07, 2010 Template instantiation without (...) | ||||
---|---|---|---|---|
| ||||
Which bit of the spec for template instantiation is it that allows the last two lines of the following to compile and work? import std.stdio; struct A { int a; } template Thingie(T) { static if (is(T == int)) enum Thingie = 1; else enum Thingie = 0; } void main() { writefln("%d", Thingie!(int)); writefln("%d", Thingie!int); writefln("%d", Thingie!A); } |
February 07, 2010 Re: Template instantiation without (...) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steve Teale | Steve Teale Wrote:
> Which bit of the spec for template instantiation is it that allows the last two lines of the following to compile and work?
>
> import std.stdio;
>
>
> struct A
> {
> int a;
> }
>
> template Thingie(T)
> {
> static if (is(T == int))
> enum Thingie = 1;
> else
> enum Thingie = 0;
> }
>
> void main()
> {
> writefln("%d", Thingie!(int));
> writefln("%d", Thingie!int);
> writefln("%d", Thingie!A);
> }
I suppose it's the part of the spec you're about to write a patch for.
|
February 07, 2010 Re: Template instantiation without (...) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Murphy | > I suppose it's the part of the spec you're about to write a patch for.
I guess so. It was discussed on one of the forums back in October 2008. I guess it got implemented but never made the documentation.
|
February 07, 2010 Re: Template instantiation without (...) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Murphy | > I suppose it's the part of the spec you're about to write a patch for. Twas at: http://www.digitalmars.com/d/archives/digitalmars/D/ Template_instantiation_syntax_77507.html#N77507 |
Copyright © 1999-2021 by the D Language Foundation