std::valarray::resize(3)
β¨ 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 ofvalarray(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
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms