Merge commit 'cf0d078a1e13fc9a3f0e290126e738976744c715'
This commit is contained in:
24
deps/nostalgia/deps/ox/src/ox/std/error.hpp
vendored
24
deps/nostalgia/deps/ox/src/ox/std/error.hpp
vendored
@ -165,21 +165,7 @@ struct [[nodiscard]] Result {
|
||||
return error == 0;
|
||||
}
|
||||
|
||||
constexpr Error copyTo(type &val) const & noexcept {
|
||||
if (!error) [[likely]] {
|
||||
val = value;
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
constexpr Error copyTo(type &val) const && noexcept {
|
||||
if (!error) [[likely]] {
|
||||
val = value;
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
constexpr Error copyTo(type &val) & noexcept {
|
||||
constexpr Error copyTo(type &val) const& noexcept {
|
||||
if (!error) [[likely]] {
|
||||
val = value;
|
||||
}
|
||||
@ -269,7 +255,7 @@ struct [[nodiscard]] Result {
|
||||
* @param alt
|
||||
* @return value of Result or alt
|
||||
*/
|
||||
constexpr T orVal(T &&alt) & noexcept {
|
||||
constexpr T or_value(T &&alt) const& noexcept {
|
||||
if (error) {
|
||||
return std::move(alt);
|
||||
}
|
||||
@ -281,7 +267,7 @@ struct [[nodiscard]] Result {
|
||||
* @param alt
|
||||
* @return value of Result or alt
|
||||
*/
|
||||
constexpr T orVal(T &&alt) && noexcept {
|
||||
constexpr T or_value(T &&alt) && noexcept {
|
||||
if (error) {
|
||||
return std::move(alt);
|
||||
}
|
||||
@ -293,7 +279,7 @@ struct [[nodiscard]] Result {
|
||||
* @param alt
|
||||
* @return value of Result or alt
|
||||
*/
|
||||
constexpr T orVal(T const&alt) & noexcept {
|
||||
constexpr T or_value(T const&alt) const& noexcept {
|
||||
if (error) {
|
||||
return alt;
|
||||
}
|
||||
@ -305,7 +291,7 @@ struct [[nodiscard]] Result {
|
||||
* @param alt
|
||||
* @return value of Result or alt
|
||||
*/
|
||||
constexpr T orVal(T const&alt) && noexcept {
|
||||
constexpr T or_value(T const&alt) && noexcept {
|
||||
if (error) {
|
||||
return alt;
|
||||
}
|
||||
|
48
deps/nostalgia/deps/ox/src/ox/std/optional.hpp
vendored
48
deps/nostalgia/deps/ox/src/ox/std/optional.hpp
vendored
@ -64,6 +64,54 @@ class Optional {
|
||||
return *m_ptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns parameter alt if Result contains an error.
|
||||
* @param alt
|
||||
* @return value of Result or alt
|
||||
*/
|
||||
constexpr T or_value(T &&alt) const& noexcept {
|
||||
if (!m_ptr) {
|
||||
return std::move(alt);
|
||||
}
|
||||
return *m_ptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns parameter alt if Result contains an error.
|
||||
* @param alt
|
||||
* @return value of Result or alt
|
||||
*/
|
||||
constexpr T or_value(T &&alt) && noexcept {
|
||||
if (!m_ptr) {
|
||||
return std::move(alt);
|
||||
}
|
||||
return std::move(*m_ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns parameter alt if Result contains an error.
|
||||
* @param alt
|
||||
* @return value of Result or alt
|
||||
*/
|
||||
constexpr T or_value(T const&alt) const& noexcept {
|
||||
if (!m_ptr) {
|
||||
return alt;
|
||||
}
|
||||
return *m_ptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns parameter alt if Result contains an error.
|
||||
* @param alt
|
||||
* @return value of Result or alt
|
||||
*/
|
||||
constexpr T or_value(T const&alt) && noexcept {
|
||||
if (!m_ptr) {
|
||||
return alt;
|
||||
}
|
||||
return std::move(*m_ptr);
|
||||
}
|
||||
|
||||
constexpr T &operator*() & noexcept {
|
||||
return *m_ptr;
|
||||
}
|
||||
|
Reference in New Issue
Block a user