472,958 Members | 1,842 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

question on map<K, V>::insert(iterator, const value& v)

consider the following program:

#include <cstdlib>
#include <iostream>
#include <map>
#include <utility>
#include <string>

using namespace std;

int main()
typedef map<int, stringcontainer_type;

container_type m;

m[0] = "zero";
m[1] = "one";
m[2] = "two";

container_type::iterator it = m.find(0);


container_type::iterator res = m.insert(m.end(), make_pair(0,

if (res == m.begin())
cout << "res equals m.begin()" << endl;
cout << "res != m.begin()" << endl;

cout << res->second << endl;


The output of the above program is

res equals m.begin()

My question: From the output, it looks like, the insert() operation
starts searching from the begin() position even though the hint is to
start at m.end() which is passed as the first argument to m.insert().
I am unable to understand this.

What actually does 'passing the iterator as hint' to the insert()
function mean ?

Does it mean, it will start searching ONLY from this hint iterator or
it will search from begin() irrespective of whatever 'hint iterator'
argument is passed(ie, in essence, it is ignored). ? How does this
version of insert() work ?

Kindly explain.

Jun 27 '08 #1
0 1353

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: pentium77 | last post by:
Basically I have a situation where I need to update changes occuring in one Text field of a table into another text field located in another table. In addition both the tables are located in...
by: Richard Cornford | last post by:
For the last couple of months I have been trying to get the next round of updates to the FAQ underway and been being thwarted by a heavy workload (the project I am working on has to be finished an...
by: Amelyan | last post by:
How can I get state of dynamically created controls (RadioButton, CheckBox, TextBox.Text) on post back when I click submit button? The only way I know is by traversing Response.Form enumberator;...
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL...
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.