[ox/std] Make Vector::erase return iterator item after removed item
This commit is contained in:
14
deps/ox/src/ox/std/error.hpp
vendored
14
deps/ox/src/ox/std/error.hpp
vendored
@ -80,7 +80,7 @@ struct Exception: public std::exception {
|
||||
uint16_t line = 0;
|
||||
ErrorCode errCode = 0;
|
||||
|
||||
explicit inline Exception(const char *file, uint32_t line, ErrorCode errCode, const char *msg = nullptr) noexcept {
|
||||
explicit inline Exception(const char *file, uint32_t line, ErrorCode errCode, const char *msg = "") noexcept {
|
||||
this->file = file;
|
||||
this->line = line;
|
||||
this->msg = msg;
|
||||
@ -88,7 +88,11 @@ struct Exception: public std::exception {
|
||||
}
|
||||
|
||||
inline explicit Exception(const Error &err) {
|
||||
this->msg = err.msg;
|
||||
if (err.msg) {
|
||||
this->msg = err.msg;
|
||||
} else {
|
||||
this->msg = "";
|
||||
}
|
||||
this->file = err.file;
|
||||
this->line = err.line;
|
||||
this->errCode = err.errCode;
|
||||
@ -121,7 +125,7 @@ struct [[nodiscard]] Result {
|
||||
constexpr Result(const type &value, const Error &error = OxError(0)) noexcept: value(const_cast<type&>(value)), error(error) {
|
||||
}
|
||||
|
||||
constexpr Result(type &&value, const Error &error = OxError(0)) noexcept: value(move(value)), error(error) {
|
||||
constexpr Result(type &&value, const Error &error = OxError(0)) noexcept: value(std::move(value)), error(error) {
|
||||
}
|
||||
|
||||
explicit constexpr operator const type&() const noexcept {
|
||||
@ -148,7 +152,7 @@ struct [[nodiscard]] Result {
|
||||
}
|
||||
|
||||
constexpr Error moveTo(type *val) noexcept {
|
||||
*val = move(value);
|
||||
*val = std::move(value);
|
||||
return error;
|
||||
}
|
||||
|
||||
@ -170,6 +174,8 @@ constexpr Error toError(const Result<T> &ve) noexcept {
|
||||
}
|
||||
|
||||
constexpr void oxIgnoreError(const ox::Error&) noexcept {}
|
||||
template<typename T>
|
||||
constexpr void oxIgnoreError(const ox::Result<T>&) noexcept {}
|
||||
#if __cplusplus >= 202002L
|
||||
#define oxReturnError(x) if (const auto _ox_error = ox::detail::toError(x)) [[unlikely]] return _ox_error
|
||||
#define oxThrowError(x) if (const auto _ox_error = ox::detail::toError(x)) [[unlikely]] throw ox::Exception(_ox_error)
|
||||
|
Reference in New Issue
Block a user