Files
Gleb MazovetskiyandClaude Fable 5 63e85d9b1b Replace tl::expected with std::expected
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]>
2026-07-22 00:00:04 +02:00

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)