![stl vector code stl vector code](https://filescnc.com/wp-content/uploads/2020/04/wp-header-logo-3239-300x300.png)
And if, for some reason, the transfer of data could be made faster by modifying the source then it would be useful to take advantage of it. The concept of copying is absolutely fine, and widely used.Įxcept when the source object won’t be used again, in which case making a copy is not the best solution.
![stl vector code stl vector code](https://mir-s3-cdn-cf.behance.net/user/138/254400433298491.5ee3ad3c36971.jpg)
![stl vector code stl vector code](https://1.bp.blogspot.com/-wUu7O7QCabo/YKnt53pQnqI/AAAAAAAAIQE/j_9H4gtLf3UnAQOpBWLjvrb6UrZW3Wh9ACLcBGAsYHQ/s2048/hackerrank-Maps-STL-in-c%252B%252B-problem-solution.png)
It makes sense because to make a copy, the source object is just used as a model and does not need to be modified. Note that the source object (the otherObject parameter) is const. MyType(MyType const& otherObject) // copy constructor Otherwise, here I am presenting just enough about move semantics in order to understand move iterators.īefore move semantics appeared, there was only one convention in C++ to instantiate an object from another object of the same type, and it was by making a copy out of it: class MyType If you’re already familiar with these then you can safely skip over to the next section. To understand move iterators, you need to understand move semantics first. Prerequisites about move semantics in C++ But by throwing in a pinch of ranges (which are expected to be the next version of the language, and are already available in Eric Niebler’s ibrary) the picture really clears up to show an impressive expressiveness in C++ code. By using the native features only, we don’t get the most out of this combinations of concepts. Move iterators are an example of how the STL collaborates with move semantics, to allow expressing several important concepts in a very well integrated piece of code. In C++11, a host of new features were introduced in the language and the Standard Library, and some of them work in synergy.