mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-19 16:15:07 +00:00
before this change, we rely on the default-generated fmt::formatter created from operator<<, but fmt v10 dropped the default-generated formatter. in this change, we define a formatter for auth::role_or_anonymous, and remove their operator<<(). Refs #13245 Signed-off-by: Kefu Chai <kefu.chai@scylladb.com> Closes scylladb/scylladb#16812
28 lines
666 B
C++
28 lines
666 B
C++
/*
|
|
* Copyright (C) 2018-present ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
#include "auth/role_or_anonymous.hh"
|
|
|
|
namespace auth {
|
|
|
|
std::ostream& operator<<(std::ostream& os, const role_or_anonymous& mr) {
|
|
os << mr.name.value_or("<anonymous>");
|
|
return os;
|
|
}
|
|
|
|
bool is_anonymous(const role_or_anonymous& mr) noexcept {
|
|
return !mr.name.has_value();
|
|
}
|
|
|
|
}
|
|
|
|
auto fmt::formatter<auth::role_or_anonymous>::format(const auth::role_or_anonymous& mr,
|
|
fmt::format_context& ctx) const -> decltype(ctx.out()) {
|
|
return fmt::format_to(ctx.out(), "{}", mr.name.value_or("<anonymous>"));
|
|
}
|