Changing all array elements at once

suggest change

Use the fill() member function to assign the same value to every element of a std::array after initialization. Class template argument deduction, used below, requires C++17:

#include <array>

int main() {
    std::array values{1, 2, 3};
    values.fill(100); // values now contains {100, 100, 100}
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents