Initialization of all elements of a multidimensional std::array to one default value
When looking for information about initialization, with a specific value, of all elements of a std::array, then based on other threads, the more direct way found would need 2 steps: std::array<double, 5> arr; arr.fill(-1.0); // output: "[-1, -1, -1, -1, -1]" And about multidimensional std::arrays, the way (continuing with the same concept above) would need 4 steps, in contrast with for example multidimensional std::vectors where the process can be done in 1 single line as shown here: #include <array> #include <cmath> #include <print> #include <vector> int main() { constexpr int r = 3; constexp
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.