Recursive Templates

BCS ao at pathlink.com
Tue Jul 29 11:41:41 PDT 2008


Reply to llee,

> Is there any way to instantiate a recursive template object. For
> example:
> 
> class Param (T) { T values; ... }
> 
> ...
> 
> Param! (Param) composite = new Param! (Param) ();
> 

No, there is no reason that you can't work with such a type but the syntax 
and type system internals make it impossible in practice.

You might be able to work around this with some combination of alias's templates 
tart resolve to types and other hacks. 

The simplest option might be something like this:

class Param (T) { ... }
class P2 : Param!(P2) {}





More information about the Digitalmars-d mailing list