C++0x issue: Constant time insertion into std::set
According to this page , I can achieve constant time insertion if I use iterator std::set::insert ( iterator position, const value_type& x ); and the position iterator I provide directly "precedes" the proper (in-order) insertion point. Now the case I'm concerned with is if I know that the value I'm inserting goes at the end (since it's the largest), e.g.: set<int> foo = {1, 2, 3}; foo.insert(4); // this is an inefficient insert According to the above criterion I should pass the last element foo.end()-1 to insert not foo.end() . Is my understanding correct? What happens if I pass foo.end() ?