Squashed 'deps/nostalgia/' changes from c90a8449..050339ba
050339ba [nostalgia] Update developer-handbook 45ec39f7 [ox/std] Add Result::orVal 319fbb26 [nostalgia] Add .lldbinit f43d97a1 [nostalgia] Add missing type descriptors a0974637 [nostalgia] Add missing test tilesheets git-subtree-dir: deps/nostalgia git-subtree-split: 050339ba09966cb9fa04747ee7bad3258bd42e55
This commit is contained in:
48
deps/ox/src/ox/std/error.hpp
vendored
48
deps/ox/src/ox/std/error.hpp
vendored
@ -264,6 +264,54 @@ struct [[nodiscard]] Result {
|
||||
return f(std::move(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns parameter alt if Result contains an error.
|
||||
* @param alt
|
||||
* @return value of Result or alt
|
||||
*/
|
||||
constexpr T orVal(T &&alt) & noexcept {
|
||||
if (error) {
|
||||
return std::move(alt);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns parameter alt if Result contains an error.
|
||||
* @param alt
|
||||
* @return value of Result or alt
|
||||
*/
|
||||
constexpr T orVal(T &&alt) && noexcept {
|
||||
if (error) {
|
||||
return std::move(alt);
|
||||
}
|
||||
return std::move(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns parameter alt if Result contains an error.
|
||||
* @param alt
|
||||
* @return value of Result or alt
|
||||
*/
|
||||
constexpr T orVal(T const&alt) & noexcept {
|
||||
if (error) {
|
||||
return alt;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns parameter alt if Result contains an error.
|
||||
* @param alt
|
||||
* @return value of Result or alt
|
||||
*/
|
||||
constexpr T orVal(T const&alt) && noexcept {
|
||||
if (error) {
|
||||
return alt;
|
||||
}
|
||||
return std::move(value);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
Reference in New Issue
Block a user