mirror of
https://github.com/diasurgical/DevilutionX.git
synced 2026-10-12 02:13:06 +00:00
Now that the project targets C++23, use the standard library's std::expected instead of the vendored tl::expected polyfill: - tl::expected -> std::expected, tl::unexpected/tl::make_unexpected -> std::unexpected - .map()/.map_error() -> .transform()/.transform_error() - #include <expected.hpp> -> #include <expected>, grouped with std headers - Remove 3rdParty/tl/expected.hpp (the tl target remains for function_ref.hpp) Co-Authored-By: Claude Fable 5 <[email protected]>
23 lines
1.1 KiB
C++
23 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include "utils/attributes.h"
|
|
|
|
#define RETURN_IF_ERROR(expr) \
|
|
if (auto result = expr; DVL_PREDICT_FALSE(!result.has_value())) { \
|
|
return std::unexpected(std::move(result).error()); \
|
|
}
|
|
|
|
#define STATUS_MACROS_CONCAT_NAME_INNER(x, y) x##y
|
|
#define STATUS_MACROS_CONCAT_NAME(x, y) STATUS_MACROS_CONCAT_NAME_INNER(x, y)
|
|
|
|
#define ASSIGN_OR_RETURN_IMPL(result, lhs, rhs) \
|
|
auto result = rhs; /* NOLINT(bugprone-macro-parentheses): assignment */ \
|
|
if (DVL_PREDICT_FALSE(!result.has_value())) { /* NOLINT(bugprone-macro-parentheses): assignment */ \
|
|
return std::unexpected(std::move(result).error()); \
|
|
} \
|
|
lhs = std::move(result).value(); /* NOLINT(bugprone-macro-parentheses): assignment */
|
|
|
|
#define ASSIGN_OR_RETURN(lhs, rhs) \
|
|
ASSIGN_OR_RETURN_IMPL( \
|
|
STATUS_MACROS_CONCAT_NAME(_result, __COUNTER__), lhs, rhs)
|