Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Best way to implement fixed size array in C++

I am trying to implement a fixed size array of 32 bit integers, but the size is determined at runtime so it has to be heap allocated. Would it be more efficient to use a c++ std::vector and use vector.reserve() or should I use the conventional way of doing it using new int32_t[size]? Additionally, would it be worth using a unique_ptr with the conventional method using new?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You would just be re-implementing std::vector. Probably badly because it takes years to figure out all the little corner cases and implement them correctly.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading