You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
vector<int> vec(other_vec.begin(), other_vec.end()); // same as other_vec
123
123
```
@@ -127,19 +127,19 @@ vector<int> vec(other_vec.begin(), other_vec.end()); // same as other_vec
127
127
128
128
- The constructor that takes another container as an argument (excepting array) assumes the container type and element type of both containers are identical. It will also copy all the elements of the received container into the new one:
129
129
```cpp
130
-
list<int> numbers = {1, 2, 3, 4, 5};
130
+
list<int> numbers = {1, 2, 3, 4, 5};
131
131
list<int> numbers2(numbers); // ok, numbers2 has the same elements as numbers
132
132
vector<int> numbers3(numbers); // error: no matching function for call...
133
133
list<double> numbers4(numbers); // error: no matching function for call...
134
134
```
135
135
- The constructor that takes two iterators as arguments does not require the container types to be identical. Moreover, the element types in the new and original containers can differ as long as it is possible to convert the elements we’re copying to the element type of the container we are initializing.
136
136
It will also copy only the object delimited by the received iterators.
137
137
```cpp
138
-
list<int> numbers = {1, 2, 3, 4, 5};
138
+
list<int> numbers = {1, 2, 3, 4, 5};
139
139
list<int> numbers2(numbers.begin(), numbers.end); // ok, numbers2 has the same elements as numbers
0 commit comments