-
-
Save ilpropheta/5cc76e9d055f949699e4c61b7fe6b8c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<typename Gen> | |
ValueType fetch_or_insert(const Key& key, Gen g) | |
{ | |
auto it = data.find(key); | |
if (it != end(data)) | |
{ | |
return it->second; | |
} | |
return data.emplace(key, g()).first->second; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment