By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,421 Members | 1,128 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,421 IT Pros & Developers. It's quick & easy.

lwg issue 233

P: n/a
I'm writing a short note on lwg issue 233 which concerns the meaning of
the iterator hint when inserting into a multimap or multiset. I would
like to include in my note a survey of current practice. To that end, I
would appreciate it if people could report back what the following
program outputs, and what compiler/library was used to generate the
results.

#include <map>
#include <iostream>

template <class Map>
void
display(const Map& m)
{
for (typename Map::const_iterator i = m.begin(), e = m.end(); i !=
e; ++i)
std::cout << '(' << i->first << ", " << i->second << ") ";
std::cout << '\n';
}

int main()
{
typedef std::multimap<int, std::string> Map;
typedef std::pair<int, std::string> value_type;
Map m;
m.insert(value_type(0, "zero"));
m.insert(value_type(1, "one"));
m.insert(value_type(2, "two"));
display(m);
m.insert(m.find(1), value_type(1, "One"));
display(m);
}

To get things started, Metrowerks CodeWarrior (all versions for many
years) outputs:

(0, zero) (1, one) (2, two)
(0, zero) (1, One) (1, one) (2, two)

Thank you for any assistance.

-Howard
Jul 23 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.