Squashed 'deps/nostalgia/' changes from 050339ba..e7a66390

e7a66390 [nostalgia/core/opengl] Fix duplicate and missing symbol
ffdc0ddb [nostalgia/core] Add support for specifying palette banks
e941781f [ox/std] Cleanup Result::copyTo variants
b869f490 [ox/std] Add or_value to Optional, Result
caf8d93c [nostalgia] Delete .gitlab-ci.yml
afbf2caf [nostalgia] Remove conan from devenv
20914eaa [nostalgia] Add Gitea action file
c5f76ff5 [nostalgia/core] Add setBgBpp function

git-subtree-dir: deps/nostalgia
git-subtree-split: e7a663901a4db72b647263c9de2ec4a45dd2e5e5
This commit is contained in:
2023-12-26 12:15:45 -06:00
parent b7278c3d04
commit cf0d078a1e
13 changed files with 168 additions and 83 deletions

View File

@ -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;
}

View File

@ -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;
}