R
Rakesh Sinha
For a particular application of mine, I need to create a considerably
huge vector, initialized with the default constructor of a given class.
For eg the code fragment might look like -
vector<MyClass> vt ;
vt.reserve(1024); // some huge number
for (int i = 0 ; i < 1024 ; i++ )
vt.push_back (MyClass() );
Instead of doing it like this, is there any other API, that would be
look like -
vector<MyClass> CreateVector<MyClass>(1024) ?
This would return a vector<MyClass> of 1024 elements all initialized
with the default constructor and initialized *quickly* compared to the
previous methodology ?
huge vector, initialized with the default constructor of a given class.
For eg the code fragment might look like -
vector<MyClass> vt ;
vt.reserve(1024); // some huge number
for (int i = 0 ; i < 1024 ; i++ )
vt.push_back (MyClass() );
Instead of doing it like this, is there any other API, that would be
look like -
vector<MyClass> CreateVector<MyClass>(1024) ?
This would return a vector<MyClass> of 1024 elements all initialized
with the default constructor and initialized *quickly* compared to the
previous methodology ?