Recursive Templates

Koroskin Denis 2korden at gmail.com
Wed Jul 30 05:38:16 PDT 2008


On Tue, 29 Jul 2008 23:59:12 +0400, Jarrett Billingsley  
<kb3ctd2 at yahoo.com> wrote:

> "llee" <llee at goucher.edu> wrote in message
> news:g6nq50$2b9n$1 at digitalmars.com...
>> I ran into a similar problem when working with sets. I could define sets
>> using templates, but I couldn't define sets of sets without the compiler
>> complaining about recursive definitions.
>>
>> For example:
>>     class Set (T) { T[] elems; ... }
>>
>> but how would I define a set of sets?.
>>
>>     Set! (Set) family = ... does not work.
>
> A set of sets of ... what?  You just need to specify what type it is.   
> "Set"
> is not a type, it is a template.
>
> Set!(Set!(int)) family;
>
>

How about, say, Set of Set of the self type? So that it becomes this:

class MySet
{
	MySet[] elems;
	// ...
}



More information about the Digitalmars-d mailing list