std::valarray::resize(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

✨ NAME ✨

okay so bestie, this page is std::valarray::resize(3) from the C++ Standard Libary manual, and the NAME section is literally std::valarray::resize - std::valarray::resize. Minimalist. Iconic. πŸ’…

πŸŽ€ Synopsis πŸŽ€

Here’s the signature, no cap:

void resize( std::size_t count, T value = T() );

It resizes the valarray so it contains count elements, and it assigns value to each element. Every single one, slay. ✨

🚨 Heads up bestie: this function invalidates all pointers and references to elements in the array. So if you had pointers or references chilling there, they’re done. periodt.

πŸ’– Parameters πŸ’–

  • count β€” new size of the container.
  • value β€” the value to initialize the new elements with.

🫢 Return value 🫢

(none) β€” literally no return value, bestie. It’s giving void. 😌

🌈 Example 🌈

Run this code, fr:

// Run this code

#include <iostream>
#include <valarray>

int main()
{
    std::valarray<int> v{1, 2, 3};
    v.resize(10);
    for (int n : v)
        std::cout << n << ' ';
    std::cout << '\n';
}

Output:

0 0 0 0 0 0 0 0 0 0

πŸ¦‹ See also πŸ¦‹

  • size β€” returns the size of valarray (public member function).

With love from http://cppreference.com on 2024.06.10, page std::valarray::resize(3) signing off πŸ’…

πŸ“¦ where this page comes from