array::assign
更新 : 2007 年 11 月
すべての要素を置き換えます。
void assign(const Ty& val);
パラメータ
- val
代入する値。
解説
このメンバ関数は、*this によって制御されているシーケンスを、値 val の N 個の要素の繰り返しで置き換えます。
使用例
// std_tr1__array__array_assign.cpp
// compile with: /EHsc
#include <array>
#include <iostream>
typedef std::tr1::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
必要条件
ヘッダー : <array>
名前空間 : std::tr1