June 2017
Intermediate to advanced
532 pages
12h 59m
English
The whole recipe revolves around the try_emplace function of std::map, which is a new C++17 addition. It has the following signature:
std::pair<iterator, bool> try_emplace(const key_type& k, Args&&... args);
Thus, the key being inserted is parameter k and the associated value is constructed from the parameter pack args. If we succeed in inserting the item, then the function returns an iterator, which points to the new node in the map, paired with a Boolean value being set to true. If the insertion was not successful, the Boolean value in the return pair is set to false, and the iterator points to the item with which the new item would clash.
This characteristic is very useful in our case--when we see a billionaire from a ...
Read now
Unlock full access