fenbf / cppstories-discussions

4 stars 1 forks source link

2019/05/heterogeneous-lookup-cpp14/ #74

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

Heterogeneous Lookup in Ordered Containers, C++14 Feature - C++ Stories

If you have a map of strings, like std::map<std::string, int> m; and you want to find some element by m.find("abc"). Do you have to pay the price and construct a std::string object? Can you optimize it? Let’s have a look at one feature enabled in C++14 that might help optimize such container access.

https://www.cppstories.com/2019/05/heterogeneous-lookup-cpp14/

kobi-ca commented 2 years ago

35% performance gain for long text (dynamic memory allocation in std::stringtemporary). have a space between string and temporary