0

Remove explicit IO manipulator support from base::ToString

This only makes sense if base::ToString() supports multiple
arguments—but it does not support multiple arguments anymore.

Bug: 399888636
Change-Id: I6b9512a01a10e80744fe6b793acec0680030d8d3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6315561
Reviewed-by: Kouhei Ueno <kouhei@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1427337}
This commit is contained in:
Daniel Cheng
2025-03-03 13:02:09 -08:00
committed by Chromium LUCI CQ
parent 5efd723cb9
commit a146c9d58c

@ -6,7 +6,6 @@
#define BASE_STRINGS_TO_STRING_H_
#include <concepts>
#include <ios>
#include <memory>
#include <sstream>
#include <string>
@ -24,21 +23,11 @@ std::string ToString(const T& values);
namespace internal {
// I/O manipulators are function pointers, but should be sent directly to the
// `ostream` instead of being cast to `const void*` like other function
// pointers.
template <typename T>
constexpr bool IsIomanip = false;
template <typename T>
requires(std::derived_from<T, std::ios_base>)
constexpr bool IsIomanip<T&(T&)> = true;
// Function pointers implicitly convert to `bool`, so use this to avoid printing
// function pointers as "true"/"false".
template <typename T>
concept WillBeIncorrectlyStreamedAsBool =
std::is_function_v<std::remove_pointer_t<T>> &&
!IsIomanip<std::remove_pointer_t<T>>;
std::is_function_v<std::remove_pointer_t<T>>;
// Fallback case when there is no better representation.
template <typename T>