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
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
fea040252d
commit
50f430b7be
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue