Bug 4056 – Template instantiation with bare parameter not documented
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dlang.org
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-04-02T21:24:00Z
Last change time
2014-02-15T02:44:31Z
Keywords
spec
Assigned to
nobody
Creator
jlquinn
Comments
Comment #0 by jlquinn — 2010-04-02T21:24:02Z
I've recently seen people using template instances like:
mytemplate!int var;
The docs don't say anything about this form, nor do the release notes for that matter. Either it's a bug (I assume not) or the spec needs to document it.
I assume this form is only good for single template parameters. Are there other limits on what parameters can be used in this way?
Comment #1 by ellery-newcomer — 2010-05-24T11:04:48Z
(In reply to comment #0)
> I've recently seen people using template instances like:
>
> mytemplate!int var;
>
> The docs don't say anything about this form, nor do the release notes for that
> matter. Either it's a bug (I assume not) or the spec needs to document it.
>
> I assume this form is only good for single template parameters. Are there
> other limits on what parameters can be used in this way?
in template.html, modify
TemplateInstance:
TemplateIdentifier !( TemplateArgumentList )
to
TemplateInstance:
TemplateIdentifier !( TemplateArgumentList )
TemplateIdentifier ! Identifier
TemplateIdentifier ! BuiltinBasicType
TemplateIdentifier ! Literal
Literal:
null
true
false
__FILE__
__LINE__
NumericLiteral
CharacterLiteral
StringLiterals
but then in declarations.html you'd have to split up BasicType a bit.
And yes, this can't work for multiple parameters because the commas would cause ambiguity with Expression. Same for identifier chains:
T!A.B == T!(A).B or T!(A.B) ?
and extended types:
T!i[] == T!(i)[] or T!(i[]) ?
etc.