mercredi 6 janvier 2016

Aggregate initialization of multidimensional std::array

I am in general familiar with aggregate initialization in C++11 but still would like to clarify the following:

Is this the correct way to initialize a two dimensional std::array with zeros?

std::array< std::array<double, N>, M > signalCorrected{{ {{0}} }};

Is it equivalent to the following when the 0 is omitted?

std::array< std::array<double, N>, M > signalCorrected{{ {{ }} }};

Will be all elements initialized to 3.1415 if I write this?

std::array< std::array<double, N>, M > signalCorrected{{ {{3.1415}} }};

What if I have a three dimensional nested std::array? Do I need to add more braces? Will the following work?

std::array< std::array< std::array<double, K>, N>, M > signalCorrected{{ {{ {{3.1415}} }} }};

Aucun commentaire:

Enregistrer un commentaire