vector_pro::operator=¶
C++
void operator= (const vector_pro<value_type>& another);
void operator= (vector_pro<value_type>&& another);
void operator= (const std::vector<value_type>& another);
void operator= (const std::initializer_list<value_type>& another);
Assign content¶
Assigns new contents to the container, replacing its current contents, and modifying its size accordingly.
copy assignment
Copies all the elements fromanotherinto the container.move assignment
Moves all the elements fromanotherinto the container.std::vector assignment
Copies all the elements fromanotherinto the container.initializer list assignment
Copies all the elements fromanotherinto the container.
Parameters¶
another
Can be astd::vector,std::inializer_listor just anothervector_pro.
Return value¶
*this .
Example¶
C++
// vector_pro::operator=
#include <iostream>
#include "vector_pro.h"
/**
* Output:
* Size of foo: 0
* Size of bar: 3
*/
int main ()
{
vector_pro<int> foo (3,0);
vector_pro<int> bar (5,0);
bar = foo;
foo = vector_pro<int>();
std::cout << "Size of foo: " << int(foo.size()) << '\n';
std::cout << "Size of bar: " << int(bar.size()) << '\n';
return 0;
}
Complexity¶
Linear in size.