Template instantiation syntax

Jason House jason.james.house at gmail.com
Fri Oct 10 18:55:14 PDT 2008


Walter Bright Wrote:

> Jason House wrote:
> > Is it ok to chain!nested!templates?  Gramatically, it's unambiguous.
> 
> No. The problem is, which is it?
> 
> a!b!c can be a!(b!c) or a!(b)!(c)

I don't know of a case where the latter is legal D. All templates that I know of require a non-templated symbol name before !(). All of the cases below are invoked as X!(...) where X isn't templated. Function calls can't return partial types. 

template X(...){...}
template X(...){ T X; }
class X(...){...}
struct X(...){...}
template X(...){ class X{...} }
template X(...){ struct X{...} } 
foo X(...){...}

Did I miss a case? The only candidate I can see is template X(...){ class X(...){...} }, but I don't know if it is legal or desirable.



More information about the Digitalmars-d mailing list