Rework Dictionary::TryGet to use std::optional.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -46,13 +46,12 @@ namespace ArbUt {
|
||||
|
||||
/// @brief Try to get an item from the dictionary using a key. Returns false if no item is found, and out will
|
||||
/// not be touched in that case.
|
||||
inline bool TryGet(const KeyT& key, ValueT& out) const noexcept {
|
||||
inline std::optional<std::reference_wrapper<const ValueT>> TryGet(const KeyT& key) const noexcept {
|
||||
const auto& find = _map.find(key);
|
||||
if (find == _map.end()) {
|
||||
return false;
|
||||
return {};
|
||||
}
|
||||
out = find->second;
|
||||
return true;
|
||||
return std::ref(find->second);
|
||||
}
|
||||
|
||||
/// @brief Removes an item with a certain key from the dictionary
|
||||
|
||||
Reference in New Issue
Block a user