This commit is contained in:
2025-10-25 03:02:53 +03:00
commit 043225d523
3416 changed files with 681196 additions and 0 deletions

159
cppdraft/valarray/cons.md Normal file
View File

@@ -0,0 +1,159 @@
[valarray.cons]
# 29 Numerics library [[numerics]](./#numerics)
## 29.6 Numeric arrays [[numarray]](numarray#valarray.cons)
### 29.6.2 Class template valarray [[template.valarray]](template.valarray#valarray.cons)
#### 29.6.2.2 Constructors [valarray.cons]
[🔗](#lib:valarray,constructor)
`valarray();
`
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7333)
*Effects*: Constructs a valarray that has zero length[.](#1.sentence-1)[249](#footnote-249 "This default constructor is essential, since arrays of valarray can be useful. After initialization, the length of an empty array can be increased with the resize member function.")
[🔗](#lib:valarray,constructor_)
`explicit valarray(size_t n);
`
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7354)
*Effects*: Constructs a valarray that has length n[.](#2.sentence-1)
Each element of the array is [value-initialized](dcl.init#def:value-initialization "9.5Initializers[dcl.init]")[.](#2.sentence-2)
[🔗](#lib:valarray,constructor__)
`valarray(const T& v, size_t n);
`
[3](#3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7366)
*Effects*: Constructs a valarray that has length n[.](#3.sentence-1)
Each element of the array is initialized with v[.](#3.sentence-2)
[🔗](#lib:valarray,constructor___)
`valarray(const T* p, size_t n);
`
[4](#4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7379)
*Preconditions*: [p, p + n) is a valid range[.](#4.sentence-1)
[5](#5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7383)
*Effects*: Constructs a valarray that has length n[.](#5.sentence-1)
The values of the elements of the array are initialized with the
firstn values pointed to by the first argument[.](#5.sentence-2)[250](#footnote-250 "This constructor is the preferred method for converting a C array to a valarray object.")
[🔗](#lib:valarray,constructor____)
`valarray(const valarray& v);
`
[6](#6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7404)
*Effects*: Constructs a valarray that has the same length as v[.](#6.sentence-1)
The elements are initialized with the values of the corresponding
elements of v[.](#6.sentence-2)[251](#footnote-251 "This copy constructor creates a distinct array rather than an alias. Implementations in which arrays share storage are permitted, but they would need to implement a copy-on-reference mechanism to ensure that arrays are conceptually distinct.")
[🔗](#lib:valarray,constructor_____)
`valarray(valarray&& v) noexcept;
`
[7](#7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7424)
*Effects*: Constructs a valarray that has the same length as v[.](#7.sentence-1)
The elements are initialized with the values of the corresponding
elements of v[.](#7.sentence-2)
[8](#8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7430)
*Complexity*: Constant[.](#8.sentence-1)
[🔗](#lib:valarray,constructor______)
`valarray(initializer_list<T> il);
`
[9](#9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7441)
*Effects*: Equivalent to valarray(il.begin(), il.size())[.](#9.sentence-1)
[🔗](#lib:valarray,constructor_______)
`valarray(const slice_array<T>&);
valarray(const gslice_array<T>&);
valarray(const mask_array<T>&);
valarray(const indirect_array<T>&);
`
[10](#10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7455)
These conversion constructors convert one of the four reference templates
to avalarray[.](#10.sentence-1)
[🔗](#lib:valarray,destructor)
`~valarray();
`
[11](#11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L7467)
*Effects*: The destructor is applied to every element of*this;
an implementation may return all allocated memory[.](#11.sentence-1)
[249)](#footnote-249)[249)](#footnoteref-249)
This default constructor is essential,
since arrays ofvalarray can be useful[.](#footnote-249.sentence-1)
After initialization, the length of an empty array can be increased with theresize member function[.](#footnote-249.sentence-2)
[250)](#footnote-250)[250)](#footnoteref-250)
This constructor is the
preferred method for converting a C array to avalarray object[.](#footnote-250.sentence-1)
[251)](#footnote-251)[251)](#footnoteref-251)
This copy constructor creates
a distinct array rather than an alias[.](#footnote-251.sentence-1)
Implementations in which arrays share storage are permitted, but they
would need to implement a copy-on-reference mechanism to ensure that arrays are
conceptually distinct[.](#footnote-251.sentence-2)