Compare commits
No commits in common. "3a781f670482d735ecb9a5c6c4b3e10362a6b56c" and "9cc27f5be9ecfb80b51623e9e08e9f9462548bc5" have entirely different histories.
3a781f6704
...
9cc27f5be9
26
deps/ox/src/ox/std/error.hpp
vendored
26
deps/ox/src/ox/std/error.hpp
vendored
@ -167,28 +167,28 @@ struct [[nodiscard]] Result {
|
|||||||
|
|
||||||
constexpr Error copyTo(type &val) const & noexcept {
|
constexpr Error copyTo(type &val) const & noexcept {
|
||||||
if (!error) [[likely]] {
|
if (!error) [[likely]] {
|
||||||
val = value;
|
*val = value;
|
||||||
}
|
}
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr Error copyTo(type &val) const && noexcept {
|
constexpr Error copyTo(type &val) const && noexcept {
|
||||||
if (!error) [[likely]] {
|
if (!error) [[likely]] {
|
||||||
val = value;
|
*val = value;
|
||||||
}
|
}
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr Error copyTo(type &val) & noexcept {
|
constexpr Error copyTo(type &val) & noexcept {
|
||||||
if (!error) [[likely]] {
|
if (!error) [[likely]] {
|
||||||
val = value;
|
*val = value;
|
||||||
}
|
}
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr Error copyTo(type &val) && noexcept {
|
constexpr Error copyTo(type &val) && noexcept {
|
||||||
if (!error) [[likely]] {
|
if (!error) [[likely]] {
|
||||||
val = std::move(value);
|
*val = std::move(value);
|
||||||
}
|
}
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
@ -200,7 +200,6 @@ struct [[nodiscard]] Result {
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
|
||||||
constexpr T &unwrap() & noexcept {
|
constexpr T &unwrap() & noexcept {
|
||||||
if (error) {
|
if (error) {
|
||||||
oxPanic(error, "Failed unwrap");
|
oxPanic(error, "Failed unwrap");
|
||||||
@ -208,7 +207,6 @@ struct [[nodiscard]] Result {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
|
||||||
constexpr T &&unwrap() && noexcept {
|
constexpr T &&unwrap() && noexcept {
|
||||||
if (error) {
|
if (error) {
|
||||||
oxPanic(error, "Failed unwrap");
|
oxPanic(error, "Failed unwrap");
|
||||||
@ -216,7 +214,6 @@ struct [[nodiscard]] Result {
|
|||||||
return std::move(value);
|
return std::move(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
|
||||||
constexpr T const&unwrap() const & noexcept {
|
constexpr T const&unwrap() const & noexcept {
|
||||||
if (error) [[unlikely]] {
|
if (error) [[unlikely]] {
|
||||||
oxPanic(error, "Failed unwrap");
|
oxPanic(error, "Failed unwrap");
|
||||||
@ -224,7 +221,6 @@ struct [[nodiscard]] Result {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
|
||||||
constexpr T &unwrapThrow() & {
|
constexpr T &unwrapThrow() & {
|
||||||
if (error) {
|
if (error) {
|
||||||
throw ox::Exception(error);
|
throw ox::Exception(error);
|
||||||
@ -232,7 +228,6 @@ struct [[nodiscard]] Result {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
|
||||||
constexpr T &&unwrapThrow() && {
|
constexpr T &&unwrapThrow() && {
|
||||||
if (error) {
|
if (error) {
|
||||||
throw ox::Exception(error);
|
throw ox::Exception(error);
|
||||||
@ -240,7 +235,6 @@ struct [[nodiscard]] Result {
|
|||||||
return std::move(value);
|
return std::move(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
|
||||||
constexpr T const&unwrapThrow() const & {
|
constexpr T const&unwrapThrow() const & {
|
||||||
if (error) {
|
if (error) {
|
||||||
throw ox::Exception(error);
|
throw ox::Exception(error);
|
||||||
@ -249,21 +243,13 @@ struct [[nodiscard]] Result {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename U = T>
|
template<typename U = T>
|
||||||
constexpr ox::Result<U> to(auto const&f) & noexcept {
|
constexpr ox::Result<U> to(const auto &f) noexcept {
|
||||||
if (error) [[unlikely]] {
|
if (error) [[unlikely]] {
|
||||||
return error;
|
return OxError(1);
|
||||||
}
|
}
|
||||||
return f(value);
|
return f(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename U = T>
|
|
||||||
constexpr ox::Result<U> to(auto const&f) && noexcept {
|
|
||||||
if (error) [[unlikely]] {
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
return f(std::move(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user