Use map::at() function for Dictionary::Get, as it already throws an exception if it doesn't exist.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-04-25 15:53:17 +02:00
parent fea040252d
commit 50f430b7be
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
1 changed files with 1 additions and 13 deletions

View File

@ -33,26 +33,14 @@ namespace Arbutils::Collections {
[[nodiscard]] inline ValueT& Get(const KeyT& key) {
#ifndef NO_ASSERT
const auto& find = _map.find(key);
if (find == _map.end()) {
throw std::logic_error("Key not found");
}
return find->second;
return _map.at(key);
#else
return _map[key];
#endif
}
[[nodiscard]] inline const ValueT& Get(const KeyT& key) const {
#ifndef NO_ASSERT
const auto& find = _map.find(key);
if (find == _map.end()) {
throw std::logic_error("Key not found");
}
return find->second;
#else
return _map.at(key);
#endif
}
inline bool TryGet(const KeyT& key, ValueT& out) const {