Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Replaces all elements.
void assign(const Ty& val);
Parameters
- val
The value to assign.
Remarks
The member function replaces the sequence controlled by *this with a repetition of N elements of value val.
Example
// std_tr1__array__array_assign.cpp
// compile with: /EHsc
#include <array>
#include <iostream>
typedef std::array<int, 4> Myarray;
int main()
{
Myarray c0 = {0, 1, 2, 3};
// display contents " 0 1 2 3"
for (Myarray::const_iterator it = c0.begin();
it != c0.end(); ++it)
std::cout << " " << *it;
std::cout << std::endl;
Myarray c1;
c1.assign(4);
// display contents " 4 4 4 4"
for (Myarray::const_iterator it = c1.begin();
it != c1.end(); ++it)
std::cout << " " << *it;
std::cout << std::endl;
return (0);
}
0 1 2 3 4 4 4 4
Requirements
Header: <array>
Namespace: std