Skip to content

Fix build error: replace C++26 std::runtime_format with C++20-compatible wrapper#7367

Merged
DennisOSRM merged 2 commits intocopilot/replace-boost-format-with-libfmtfrom
copilot/fix-build-errors
Feb 19, 2026
Merged

Fix build error: replace C++26 std::runtime_format with C++20-compatible wrapper#7367
DennisOSRM merged 2 commits intocopilot/replace-boost-format-with-libfmtfrom
copilot/fix-build-errors

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 19, 2026

std::runtime_format is a C++26 feature, but was used unconditionally in the OSRM_HAS_STD_FORMAT branch, which activates as soon as C++20 std::format is detected — causing a build failure with clang++-16.

Changes

  • include/util/format.hpp: Replace using std::runtime_format with a C++20-compatible shim:
    • RuntimeFormatString — lightweight wrapper around std::string_view
    • runtime_format(std::string_view) — factory mirroring the fmt::runtime() API
    • format(RuntimeFormatString, Args...) — overload dispatching to std::vformat (available since C++20)
// Before (C++26 only)
using std::runtime_format;

// After (C++20 compatible)
struct RuntimeFormatString { std::string_view str; };
inline RuntimeFormatString runtime_format(std::string_view s) { return {s}; }

template <typename... Args>
std::string format(RuntimeFormatString fmt, Args &&...args) {
    return std::vformat(fmt.str, std::make_format_args(std::forward<Args>(args)...));
}

Compile-time format("{}", x) calls remain unambiguous — std::format_string<Args...> has a consteval constructor and cannot be satisfied by RuntimeFormatString, so overload resolution is clean.

Original prompt

Reference: https://github.com/Project-OSRM/osrm-backend/actions/runs/22181239635/job/64143246355#step:14:1

Fix the build errors


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…at wrapper

Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>
@DennisOSRM DennisOSRM marked this pull request as ready for review February 19, 2026 16:01
@DennisOSRM DennisOSRM merged commit 325864d into copilot/replace-boost-format-with-libfmt Feb 19, 2026
@DennisOSRM DennisOSRM deleted the copilot/fix-build-errors branch February 19, 2026 16:01
Copilot AI restored the copilot/fix-build-errors branch February 19, 2026 16:02
Copilot AI changed the title [WIP] Fix build errors in project Fix build error: replace C++26 std::runtime_format with C++20-compatible wrapper Feb 19, 2026
Copilot AI requested a review from DennisOSRM February 19, 2026 16:02
Copilot stopped work on behalf of DennisOSRM due to an error February 19, 2026 16:02
DennisOSRM added a commit that referenced this pull request Feb 21, 2026
* Initial plan

* Replace boost::format with libfmt across the codebase

Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>

* Remove unnecessary util/log.hpp include from shared_monitor.hpp

Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>

* Fix code formatting as reported by CI

Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>

* Fix npm audit security vulnerability in tar package

Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>

* Add missing <memory> include to multi_level_partition.hpp

Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>

* Add missing <memory> include to compressed_edge_container.hpp

Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>

* Add missing <vector> include to io_config.hpp

Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>

* Add missing <string> and <cstring> includes to storage headers

Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>

* Add missing includes: util/format.hpp and <vector>

Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>

* Fix runtime format string handling for C++20 std::format compatibility

Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>

* [WIP] Fix build errors in project (#7367)

* Fix clang-format-18 formatting in include/util/format.hpp (#7368)

* Fix std::make_format_args rvalue binding error with GCC 13 (#7369)

* Fix missing `<unistd.h>` include for macOS in io-benchmark (#7370)

* Move `#ifdef OSRM_HAS_STD_FORMAT` from call sites into `format.hpp` (#7371)

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>
Co-authored-by: Dennis Luxen <info@project-osrm.org>
MarcelloPerathoner pushed a commit to MarcelloPerathoner/osrm-backend that referenced this pull request Feb 24, 2026
* Initial plan

* Replace boost::format with libfmt across the codebase

Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>

* Remove unnecessary util/log.hpp include from shared_monitor.hpp

Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>

* Fix code formatting as reported by CI

Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>

* Fix npm audit security vulnerability in tar package

Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>

* Add missing <memory> include to multi_level_partition.hpp

Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>

* Add missing <memory> include to compressed_edge_container.hpp

Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>

* Add missing <vector> include to io_config.hpp

Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>

* Add missing <string> and <cstring> includes to storage headers

Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>

* Add missing includes: util/format.hpp and <vector>

Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>

* Fix runtime format string handling for C++20 std::format compatibility

Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>

* [WIP] Fix build errors in project (Project-OSRM#7367)

* Fix clang-format-18 formatting in include/util/format.hpp (Project-OSRM#7368)

* Fix std::make_format_args rvalue binding error with GCC 13 (Project-OSRM#7369)

* Fix missing `<unistd.h>` include for macOS in io-benchmark (Project-OSRM#7370)

* Move `#ifdef OSRM_HAS_STD_FORMAT` from call sites into `format.hpp` (Project-OSRM#7371)

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>
Co-authored-by: Dennis Luxen <info@project-osrm.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants