insert

C++ Reference

insert
Syntax:
  #include <set>
  iterator insert( iterator i, const TYPE& val );
  void insert( input_iterator start, input_iterator end );
  pair<iterator,bool> insert( const TYPE& val );

The function insert() either:

  • inserts val after the element at pos (where pos is really just a suggestion as to where val should go, since sets and maps are ordered), and returns an iterator to that element.
  • inserts a range of elements from start to end.
  • inserts val, but only if val doesn't already exist. The return value is an iterator to the element inserted, and a boolean describing whether an insertion took place.
Related topics: