vendredi 3 juillet 2015

Fastest and most concise way to init a 2D std::array with computed value

Looking for a C++11/14 syntax where I can assign a computed value to each cell of the inner array for my 2D array (the outer array being an array for those inner lines):

void foo(std::array<std::array<char, NCOLS>, NROWS>& other_array) {
  float value = 42.0;
  std::array<std::array<float, other_array[0].size()>, 

other_array.size()> new_array; // HOW DO I ASSIGN value to all elements?
  // .../...
}

Aucun commentaire:

Enregistrer un commentaire