Implicit Template Properties - rules change proposal

Sean Kelly sean at f4.ca
Tue Jun 20 13:44:04 PDT 2006


Tom S wrote:
> I often find myself creating templates like:
> 
> // ----
> tempate doSomethingImpl(T) {
>     template loop(int i) {
>         ....
>         alias ... loop;
>     }
> 
>     alias loop!(0) res;
> }
> 
> template doSomething(T) {
>     alias doSomethingImpl!(T).res doSomething;
> }
> // ----
> 
> Clearly the second template is redundant and exists there only to make 
> the usage pattern easier.
> My proposal is to change the rules for implicit template properties
> 
> from:
> "If a template has exactly one member in it, and the name of that member 
> is the same as the template name, that member is assumed to be referred 
> to in a template instantiation"
> 
> to:
> "If a template has exactly one *public* member in it, (...) "
> 
> 
> Then, the template would look like:
> 
> // ----
> tempate doSomething(T) {
>     private template loop(int i) {
>         ....
>         alias ... loop;
>     }
> 
>     alias loop!(0) doSomething;
> }
> // ----
> 
> Opinions ?

This would be awesome.


Sean



More information about the Digitalmars-d mailing list