Skip to content

Tag Archives: cpp-iterator

The STL is a very powerful library in C++. It is strongly built on the principles of template programming. The STL library has three main… Read More
std::advance and std::next are used to advance the iterator by a certain position, such that we can make the iterator point to a desired position.… Read More
std::prev returns an iterator pointing to the element after being advanced by certain no. of positions in the reverse direction. It is defined inside the… Read More
std::next returns an iterator pointing to the element after being advanced by certain no. of positions. It is defined inside the header file . It… Read More
An iterator is an object (like a pointer) that points to an element inside the container. We can use iterators to move through the contents… Read More
After going through the template definition of various STL algorithms like std::reverse, std::next_permutation and std::reverse_copy you must have found their template definition consisting of objects… Read More
After going through the template definition of various STL algorithms like std::copy, std::move, std::transform, you must have found their template definition consisting of objects of… Read More
After going through the template definition of various STL algorithms like std::search, std::search_n, std::lower_bound, you must have found their template definition consisting of objects of… Read More
After going through the template definition of various STL algorithms like std::nth_element, std::sort, you must have found their template definition consisting of objects of type… Read More
std::back_inserter constructs a back-insert iterator that inserts new elements at the end of the container to which it is applied. It is defined inside the… Read More
std::inserter constructs an insert iterator that inserts new elements into x in successive locations starting at the position pointed by it. It is defined inside… Read More
std::front_inserter constructs a front-insert iterator that inserts new elements at the front of the container to which it is applied. It is defined inside the… Read More
After going through the template definition of various STL algorithms like std::find, std::equal, std::count, you must have found their template definition consisting of objects of… Read More
If we have two iterators and we want to find the total no. of elements between the two iterators, then that is facilitated by std::distance(),… Read More
std::advance advances the iterator ‘it’ by n element positions. Syntax : template void advance (InputIterator& it, Distance n); it : Iterator to be advanced n… Read More