Replace tl::expected and libfmt with standard libary equivalents - #8618
Merged
Conversation
glebm
force-pushed
the
std-format
branch
6 times, most recently
from
July 13, 2026 16:59
2cb5161 to
5d7acaf
Compare
glebm
marked this pull request as ready for review
July 13, 2026 17:09
glebm
enabled auto-merge (rebase)
July 13, 2026 17:09
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 <noreply@anthropic.com>
These toolchains haven't updated their libcxx in years. Disables these CI builds in order to avoid being stuck on old language level support. Once / if the toolchains are updated, we can re-enable these platforms. Toolchain update bugs: * PS4: OpenOrbis/OpenOrbis-PS4-Toolchain#262 * Xbox nxdk: XboxDev/nxdk-libcxx#3
Includes diasurgical/asio@112f011, which fixes a C++23 deprecation warning
- `fmt::format` with literal format strings -> `std::format`. - `fmt::format(fmt::runtime(...))` -> `FormatRuntime` in the new `utils/format.hpp`, a std::vformat wrapper that is also safe under the P2905 lvalue requirement of `std::make_format_args`. - `fmt::dynamic_format_arg_store` (Lua logging) -> a small hand-rolled per-field formatter over `std::variant`, returning `std::expected`. - `fmt::format_int` -> `std::to_chars`. - `fmt::join` -> manual joins at the two call sites. - SDL_audiolib: new patch that rewrites aulib_log.h to use std::format and drops the fmt dependency from its CMakeLists. - The `-static-libstdc++` guard now keys off `DEVILUTIONX_STATIC_SDL_AUDIOLIB` instead of `DEVILUTIONX_STATIC_LIBFMT`. - libfmt removed from CMake, vcpkg, Brewfile, CI workflows, Dockerfiles, packaging scripts, UWP project, and docs. - macOS bumped to 13.3+, iOS to 16.3+ (required for `<format>`) - Amiga m68k: provide `__cmpdf2`, which is missing from the hard-float libgcc multilib but referenced via libstdc++'s long double paths. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
AJenbo
reviewed
Jul 19, 2026
AJenbo
reviewed
Jul 21, 2026
| * `std::format` has no equivalent of `fmt::dynamic_format_arg_store`, so we | ||
| * parse the replacement fields ourselves and format each one individually. | ||
| */ | ||
| std::expected<std::string, std::string> FormatLuaMessage(std::string_view fmt, std::span<const LuaFormatArg> args) |
Member
There was a problem hiding this comment.
This is the only function that gives me a bit of pause, but it's not something that is normally used heavily so not a big issue.
Collaborator
Author
There was a problem hiding this comment.
Yeah it's a bit unfortunate that std::format doesn't support dynamic format arguments but we're unlikely to need anything more than this very basic formatting here.
AJenbo
approved these changes
Jul 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
tl::expected -> std::expected
[[nodiscard]] warning fixes
std::expectedis annotated as[[nodiscard]]and switching to it surfaced several warnings for places where we were silently dropping the errors. A commit here fixes most of these.fmt::format -> std::format
fmt::formatwith literal format strings ->std::format.fmt::format(fmt::runtime(...))->FormatRuntimein the newutils/format.hpp, anstd::vformatwrapper that is also safe under the P2905 lvalue requirement ofstd::make_format_args.fmt::dynamic_format_arg_store(Lua logging) -> a small hand-rolled per-field formatter overstd::variant, returningstd::expected.fmt::format_int->std::to_chars.fmt::join-> manual joins at the two call sites.aulib_log.hto usestd::formatand drops the fmt dependency from its CMakeLists.-static-libstdc++guard now keys offDEVILUTIONX_STATIC_SDL_AUDIOLIBinstead ofDEVILUTIONX_STATIC_LIBFMT.<format>)Disable PS4 and Xbox NXDK CI
These platforms have obsolete toolchains, disables them for now to avoid being stuck on old language level for who knows how long. Once the toolchains are updated, we can re-enable them.
Tracking bugs for libcxx update:
Failing builds: