samedi 3 décembre 2016

WANTED: POD real and complex vectors and arrays

I have a C++ application that uses lots of arrays and vectors of real values (doubles) and complex values. I do not want them initialized to zeros. Hey compiler and STL! - just allocate the dang memory and be done with it. It's on me to put the right values in there. Should I fail to do so, I want the program to crash during testing.

I managed to prevent std::vector from initializing with zeros by defining a custom allocator for use with POD's. (Is there a better way?)

What to do about std::complex? It is not defined as a POD. It has a default constructor that spews zeros. So if I write

std::complex<double> A[compile_time_const];

it spews. Ditto for

std::array <std::complex<double>, compile_time_constant>;

What's the best way to utilize the std::complex<> functionality without provoking swarms of zeros?

Aucun commentaire:

Enregistrer un commentaire