Class allocation from tuple

Robert Fraser fraserofthenight at gmail.com
Thu May 21 10:40:34 PDT 2009


bearophile wrote:
> I have a tuple of classes (D1 language), I'd like to instantiate one of them directly with new, but it seems I can't:
> 
> template Tuple(T...) { alias T Tuple; }
> 
> class Foo { static void foo(){} }
> class Bar {}
> alias Tuple!(Foo, Bar) ClassTuple;
> 
> void main() {
>     alias ClassTuple[0] Foo0;
>     new Foo0; // OK
> 
>     ClassTuple[0].foo(); // OK
> 
>     new ClassTuple[0]; // Not OK
>     new (ClassTuple[0]); // Not OK
> }
> 
> Can you tell me what the problem is?
> 
> Thank you and bye,
> bearophile

alias


More information about the Digitalmars-d-learn mailing list