lwg issue 233

H

Howard Hinnant

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,058
Latest member
QQXCharlot

Latest Threads

Top