I have a class that is not explicitly copied (stream, so there is no copy semantics that make sense), and I want to have a large "array" of them, identically constructed with a constructor that is different from the standard one. Note that the array has a fixed size.
I can only use the default constructor with C ++ arrays if I do not initialize each of them myself.
Thread myArray[128]; // uses default constructor - wrong
I can explicitly specify the constructors and parameters of the object, but this detailed and ugly
Thread myArray[128] = { Thread(params,...), Thread(params,...), ... x 128 ;
It seems I can not use stl vectors because the object is not copied - an event, although the vector never changes size. I think the constructor really copies!
std::vector<Thread> myVector(128, Thread(params,...));
The way I do this is an array of smart pointers and an initialization loop, but maybe I missed something:
Is there any other way - maybe with forced containers or with another type of container?
Roddy
source share