On Saturday, 24 October 2015 at 16:58:58 UTC, qsdfghjk wrote:
On Saturday, 24 October 2015 at 15:57:09 UTC, Dandyvica wrote:
Hi guys,
Apart from deriving from the same class and declaring an array
of that
root class, is there a way to create an array of templates?
This seems not possible since template are compile-time
generated, but just to be sure. For example, it seems logical
to get an array of complex numbers but Complex needs to be
declared with a type.
Thanks for any hint.
You can declare an array whose the element type matches to one
of the template parameter:
---
struct Foo(T)
{
Foo!T[] foos;
// typeof(this)[] foos // equivalent
}
---
since it's an array (fixed size whatever is the element type:
size_t len + size_t pointer) it doesn't matter if the template
declaration is partial.
In that case, all elements have the same type right? I'd like
different types,
but with the same template.