Merge commit 'b7278c3d04920a4fe55abd8d7ad0727f6ecde21a'

This commit is contained in:
2023-12-23 19:12:16 -06:00
10 changed files with 298 additions and 8 deletions

View File

@ -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 {