On Monday 7. December 2015 08:28:53 Thiago Macieira wrote:
> What const is missing? Are you saying it should have been
> 
>       for (const std::pair<const std::string, std::string> &e: stdMap)

Yes.

The value_type of a std::map<Key,T>  is std::pair<const Key, T>.

It allows to do this:

   // add "foobar" to all the entries
   for (auto &e: stdMap)
         e.second += "foobar";

But it does not allow to change the key because that cannot be changed via an 
iterator.  

> If so, I consider that an API defect in std::map 

Quite the contrary.

> or an implementation defect in std::string in the first place. It wouldn't
> cause a magnitude of performance difference if they were implicitly shared,
> like QString.

That's another issue.

-- 
Olivier 

Woboq - Qt services and support - http://woboq.com - http://code.woboq.org


_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to