Skip to content

Convert std::stringstream to C++20 std::format (see #3590)#4064

Open
magreenblatt wants to merge 1 commit into
chromiumembedded:masterfrom
magreenblatt:cppformat
Open

Convert std::stringstream to C++20 std::format (see #3590)#4064
magreenblatt wants to merge 1 commit into
chromiumembedded:masterfrom
magreenblatt:cppformat

Conversation

@magreenblatt

Copy link
Copy Markdown
Collaborator

Replace std::stringstream usage with std::format for string formatting throughout the CEF codebase. This improves code readability and leverages C++20's type-safe, compile-time validated formatting.

Also removes unused includes and replaces stream accumulator patterns with more efficient std::string += operations where appropriate.

…3590)

Replace std::stringstream usage with std::format for string formatting
throughout the CEF codebase. This improves code readability and
leverages C++20's type-safe, compile-time validated formatting.

Also removes unused <sstream> includes and replaces stream accumulator
patterns with more efficient std::string += operations where appropriate.
@magreenblatt

Copy link
Copy Markdown
Collaborator Author

We'll need to wait on this PR due to tooling support limitations.

GCC doesn't support std::format until GCC13:

cef_binary/distrib/libcef_dll/base/cef_logging.cc:27:10: fatal error: format: No such file or directory

Xcode requires a deployment target >= 13.3 to use std::to_char (a std::format implementation dependency):

Xcode-1600.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/c++/v1/__format/formatter_floating_point.h:66:30: error: 'to_chars' is unavailable: introduced in macOS 13.3
      66 |   to_chars_result __r = std::to_chars(__first, __last, __value, __fmt);
         | 
...
cef_binary/distrib/libcef_dll/wrapper/cef_xml_object.cc:65:24: note: in instantiation of function template specialization 'std::format<int>' requested here
      65 |                   std::format("Value following child element, line {}",
         |                        ^
Xcode-1600.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/c++/v1/__charconv/to_chars_floating_point.h:42:1: note: 'to_chars' has been explicitly marked unavailable here
      42 | to_chars(char* __first, char* __last, long double __value, chars_format __fmt);
         | ^

@magreenblatt

Copy link
Copy Markdown
Collaborator Author

This conversion was performed by Claude Code following the plan in CPP20FORMAT.md

@magreenblatt magreenblatt added the blocked Blocked on some other issue/action label Jan 5, 2026
@sergio-nsk

sergio-nsk commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Shouldn't CEF follow the guide "Modern C++ use in Chromium" that banns <format>?

@magreenblatt

Copy link
Copy Markdown
Collaborator Author

Shouldn't CEF follow the guide "Modern C++ use in Chromium" that banns ?

We should avoid usage in Chromium-linked code (e.g. libcef), but it should be fine in CEF wrapper and client code where base and absl print functions are not currently available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocked Blocked on some other issue/action

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants