Use std::optional for BaseLibrary TryGet.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
@@ -39,12 +39,11 @@ namespace CreatureLib::Library {
|
||||
bool TryGet(const ArbUt::BasicStringView& name, ArbUt::BorrowedPtr<const T>& out) const noexcept {
|
||||
return TryGet(name.GetHash(), out);
|
||||
}
|
||||
bool TryGet(uint32_t hashedKey, ArbUt::BorrowedPtr<const T>& out) const noexcept {
|
||||
std::optional<ArbUt::BorrowedPtr<const T>> TryGet(uint32_t hashedKey) const noexcept {
|
||||
auto find = _values.GetStdMap().find(hashedKey);
|
||||
if (find == _values.GetStdMap().end())
|
||||
return false;
|
||||
out = std::get<1>(*find);
|
||||
return true;
|
||||
return {};
|
||||
return std::get<1>(*find);
|
||||
}
|
||||
|
||||
[[nodiscard]] inline ArbUt::BorrowedPtr<const T> Get(const ArbUt::BasicStringView& name) const {
|
||||
|
||||
Reference in New Issue
Block a user