Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::valarray<T>::resize

      From cppreference.com
      <cpp‎ |numeric‎ |valarray
       
       
       
      std::valarray
      Member functions
      Non-member functions
      Helper classes
      Deduction guides(C++17)
       
      void resize(std::size_t count, T value= T());

      Resizes the valarray to containcount elements and assignsvalue to each element.

      This functions invalidates all pointers and references to elements in the array.

      Contents

      [edit]Parameters

      count - new size of the container
      value - the value to initialize the new elements with

      [edit]Return value

      (none)

      [edit]Example

      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

      [edit]See also

      returns the size of valarray
      (public member function)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/numeric/valarray/resize&oldid=160815"

      [8]ページ先頭

      ©2009-2025 Movatter.jp