C++ Set Library - insert Function


Description

It extends the container by inserting new elements.

Declaration

Following are the ways in which std::set::insert works in various C++ versions.

C++98

pair<iterator,bool> insert (const value_type& val);

C++11

pair<iterator,bool> insert (const value_type& val);
pair<iterator,bool> insert (value_type&& val);

Return value

It returns a pair with its members.

Exceptions

If a single element is to be inserted, there are no changes in the container in case of exception.

Time complexity

Time complexity is contstant.

set.htm
Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements