[Issue 242] template implicit template properties doesn't work

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Nov 28 07:43:32 PST 2006


http://d.puremagic.com/issues/show_bug.cgi?id=242





------- Comment #1 from wbaxter at gmail.com  2006-11-28 09:43 -------
(In reply to comment #0)
> template x() { template x() { const x = 1; } }
> void main() { const y = x!()!(); }
> 
> Gives:
> test.d(2): semicolon expected following auto declaration, not '!'
> test.d(2): found '!' instead of statement
> 
> Instead, trying const y = x!().x!(), gives 
> 
> test.d(2): template identifier x is not a member of x
> 
> I can't see any way to instantiate the inner template when it is "an implicit
> template property".
> 

Especially now with tuples, it would be nice if something like the x!()!()
above worked.  Because:
* A template can only have one tuple parameter.
* Multiple tuples passed into a tuple-taking template get merged into a single
tuple.

Thus nested tuple templates seems to be the best hope for writing algorithms
that process or combine multiple tuples.

  template x(S...) { template x(T...) { /*use S and T together*/ } }

  x!(int,float)!(3,24.0)

(And even if the inner one is not named x, you still can't do x!().y!() right
now.)


-- 




More information about the Digitalmars-d-bugs mailing list