Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sstring: deprecate formatters for vector and unordered_map #2256

Merged
merged 1 commit into from
May 21, 2024

Conversation

tchaikov
Copy link
Contributor

Seastar is an event-driven framework, not a collection of libraries for multiple purposes. also, when migrating to a {fmt} only formatting solution, the operator<< based printers can actually makes our lives more difficult. for instance, Boost.test expects operator<< and fall back to boost_test_print_type(), so even if we provide a templated boost_test_print_type() which accepts all types which can be formatted with {fmt}, if Boost.test is able to find the operator<<-based formatter for a std::vector, it just picks it, and then hits the brick wall, as the elements in the vector does not provide an operator<<-based formatter.

instead of enabling these operator<<:s to print the element with fmt::formatter support, let's just disable them on user's request.

in this change, a new option is added. so that user can disable these formatter on request. and these two formatters are marked deprecated. so in future, we can remove them when we bump up the API level or just completely drop them.

Fixes #1544
Signed-off-by: Kefu Chai [email protected]

Copy link
Member

@bhalevy bhalevy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Seastar is an event-driven framework, not a collection of libraries
for multiple purposes. also, when migrating to a {fmt} only formatting
solution, the operator<< based printers can actually makes our lives
more difficult. for instance, Boost.test expects operator<< and fall
back to `boost_test_print_type()`, so even if we provide a templated
`boost_test_print_type()` which accepts all types which can be formatted
with {fmt}, if Boost.test is able to find the operator<<-based
formatter for a std::vector, it just picks it, and then hits the brick
wall, as the elements in the vector does not provide an operator<<-based
formatter.

instead of enabling these operator<<:s to print the element with
fmt::formatter support, let's just disable them on user's request.

in this change, a new option is added. so that user can disable these
formatter on request. and these two formatters are marked deprecated.
so in future, we can remove them when we bump up the API level or just
completely drop them.

Fixes scylladb#1544
Signed-off-by: Kefu Chai <[email protected]>
@tchaikov tchaikov force-pushed the deprecate-std-formatters branch from 7a5431b to 3e2977b Compare May 21, 2024 14:11
@@ -858,6 +861,7 @@ std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {

SEASTAR_MODULE_EXPORT
template <typename Key, typename T, typename Hash, typename KeyEqual, typename Allocator>
[[deprecated("Use {fmt} instead")]]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(or write your own), but it's good advice.

@avikivity avikivity merged commit 914a424 into scylladb:master May 21, 2024
14 checks passed
@tchaikov tchaikov deleted the deprecate-std-formatters branch May 21, 2024 15:07
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.

Deprecate public range print helpers
3 participants