std::valarray::valarray(3)

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

πŸ’– NAME πŸ’–

okay so this is the std::valarray::valarray(3) page β€” a C++ Standard Library manual page, bestie, and it's literally all about the constructors of std::valarray. yes, the whole page. every single way to birth a valarray. there are eleven of them. buckle up πŸŽ€


✨ Synopsis ✨

look at this lineup, it's giving opening night at the constructors' ball πŸ‘‘

valarray();                                   (1)
explicit valarray( std::size_t count );       (2)
valarray( const T& val, std::size_t count );  (3)
valarray( const T* vals, std::size_t count ); (4)
valarray( const valarray& other );            (5)
valarray( valarray&& other ) noexcept;        (6)  (since C++11)
valarray( const std::slice_array<T>& sa );    (7)
valarray( const std::gslice_array<T>& gsa );  (8)
valarray( const std::mask_array<T>& ma );     (9)
valarray( const std::indirect_array<T>& ia ); (10)
valarray( std::initializer_list<T> il );      (11) (since C++11)

so what do they do? they construct a new numeric array from various sources. that's the vibe. 🌈

  1. Default constructor. Constructs an empty numeric array. nothing in it. empty. a little baby void. 🫧
  2. Constructs a numeric array with count copies of value-initialized elements.
  3. Constructs a numeric array with count copies of val.
  4. Constructs a numeric array with copies of count values from an array pointed to by vals. careful though β€” if this array contains less than count values, the behavior is undefined. 😭 like actually undefined, not the cute kind.
  5. Copy constructor. Constructs the numeric array with the copy of the contents of other.
  6. Move constructor. Constructs the container with the contents of other using move semantics. note the noexcept β€” she's smooth. πŸ’…
  7. 8. 9. 10. β€” Converting constructor. Convert the corresponding data structure to a valarray. all four of them, same energy, different source shape ✨
  8. Constructs the numeric array with the contents of the initializer list il.

🌸 Parameters 🌸

  • count β€” the number of elements to construct
  • val β€” the value to initialize the elements with
  • vals β€” pointer to a C array to use as source to initialize the contents
  • other β€” another numeric array to use as source to initialize the contents
  • sa β€” slice array to initialize the elements with
  • gsa β€” generic slice array to initialize the elements with
  • ma β€” mask array to initialize the elements with
  • ia β€” indirect array to initialize the elements with
  • il β€” initializer list to initialize the elements with

😭 Exceptions 😭

  • 1-5, 7-11) May throw implementation-defined exceptions.

(yeah, 6 is missing from that list β€” it's the noexcept one, iykyk πŸ¦‹)


πŸŽ€ Example πŸŽ€

This section is incomplete Reason: no example

not me showing up to the example section and it's empty πŸ’€ literally nothing here. we move.


πŸ‘‘ Category: πŸ‘‘

  • Todo no example

and that's the whole page, bestie β€” no notes, no cap, every constructor accounted for πŸ’œ

shoutout to the source, http://cppreference.com, dated 2024.06.10 β€” that's the page version and date, go give the cppreference girlies their flowers 🌸

πŸ“¦ where this page comes from