array of elements of various subclasses

spir denis.spir at gmail.com
Sun Nov 7 09:50:00 PST 2010


On Sun, 07 Nov 2010 20:29:40 +0300
Dmitry Olshansky <dmitry.olsh at gmail.com> wrote:

> On 07.11.2010 18:49, spir wrote:
> > On Sun, 7 Nov 2010 16:17:38 +0100
> > spir<denis.spir at gmail.com>  wrote:
> >
> > And I'd like to know, as a possible workaround, if there is a way to save a variadic arg list:
> > 	class C {
> > 	    ??? xs;
> > 	    this(X xs...) {
> > 	        this.xs = xs;
> > 	    }
> > 	}
> >
> > Denis
> > -- -- -- -- -- -- --
> > vit esse estrany ☣
> >
> > spir.wikidot.com
> >
> Tuple!(X) from std.typecons should do
> 

Refused with the same error, plus two more:
DeeMatch.d(372): Error: cannot implicitly convert expression (patterns) of type DeeMatch.Pattern to Tuple!(Pattern)
DeeMatch.d(380): Error: no property 'opApply' for type 'Tuple!(Pattern)'
DeeMatch.d(380): Error: opApply() function for Tuple!(Pattern) must return an int

Actually, seems Tuple!(Pattern) defines a type for singleton Pattern tuples (Tuple!(A,B) is a type for 2-tuples). Not for a variadic list of Pattern element.
The two other errors refer to where I try to use the field 'patterns' in a foreach loop.

Denis

-- -- -- -- -- -- --
vit esse estrany ☣

spir.wikidot.com



More information about the Digitalmars-d-learn mailing list