diff --git a/CMakeLists.txt b/CMakeLists.txt index e5b9ce8959a..9fd47b9fe03 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,6 +65,10 @@ option (Seastar_SSTRING "Use seastar's own string implementation" ON) +option (Seastar_DEPRECATED_OSTREAM_FORMATTERS + "Enable operator<< for formatting standard library containers, which will be deprecated in future" + ON) + set (Seastar_API_LEVEL "7" CACHE @@ -927,6 +931,11 @@ if (Seastar_SSTRING) PUBLIC SEASTAR_SSTRING) endif () +if (Seastar_DEPRECATED_OSTREAM_FORMATTERS) + target_compile_definitions (seastar + PUBLIC SEASTAR_DEPRECATED_OSTREAM_FORMATTERS) +endif () + if (LinuxMembarrier_FOUND) list (APPEND Seastar_PRIVATE_COMPILE_DEFINITIONS SEASTAR_HAS_MEMBARRIER) diff --git a/include/seastar/core/sstring.hh b/include/seastar/core/sstring.hh index 3add17492e5..d6e0de46eae 100644 --- a/include/seastar/core/sstring.hh +++ b/include/seastar/core/sstring.hh @@ -836,10 +836,13 @@ string_type to_sstring(T value) { } } +#ifdef SEASTAR_DEPRECATED_OSTREAM_FORMATTERS + namespace std { SEASTAR_MODULE_EXPORT template +[[deprecated("Use {fmt} instead")]] inline std::ostream& operator<<(std::ostream& os, const std::vector& v) { bool first = true; @@ -858,6 +861,7 @@ std::ostream& operator<<(std::ostream& os, const std::vector& v) { SEASTAR_MODULE_EXPORT template +[[deprecated("Use {fmt} instead")]] std::ostream& operator<<(std::ostream& os, const std::unordered_map& v) { bool first = true; os << "{"; @@ -874,6 +878,8 @@ std::ostream& operator<<(std::ostream& os, const std::unordered_map= 90000 // Due to https://github.com/llvm/llvm-project/issues/68849, we inherit