template ref parameter

Jonathan M Davis jmdavisProg at gmx.com
Wed Nov 21 03:31:04 PST 2012


On Wednesday, November 21, 2012 11:55:53 Jack Applegame wrote:
> Why this could not compile?
> 
> struct Foo(T) {}
> Foo!(ref int) foo;
> 
> Output:
> 
> Error: expression expected, not 'ref'
> Error: found 'int' when expecting ')' following template argument
> list
> Error: no identifier for declarator Foo!(0)
> Error: semicolon expected, not ')'
> Error: found ')' instead of statement

ref is not part of a type. It's only a storage class, and it's only legal on 
function parameters, return types, and foreach's loop variables. It's not 
legal on local variables or member variables or anything of the sort. So, ref 
int for a template argument makes no sense whatsoever.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list