Skip to content

Commit

Permalink
mutation: range_tombstone: specialize fmt::formatter<range_tombstone>
Browse files Browse the repository at this point in the history
this is a part of a series to migrating from `operator<<(ostream&, ..)`
based formatting to fmtlib based formatting. the goal here is to enable
fmtlib to print range_tombstone.

Refs scylladb#13245

Signed-off-by: Kefu Chai <[email protected]>
  • Loading branch information
tchaikov committed Mar 21, 2023
1 parent 34d4117 commit 4af0a0e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions mutation/range_tombstone.hh
Original file line number Diff line number Diff line change
Expand Up @@ -286,3 +286,16 @@ public:

void clear();
};

template<>
struct fmt::formatter<range_tombstone> : fmt::formatter<std::string_view> {
template <typename FormatContext>
auto format(const range_tombstone& rt, FormatContext& ctx) const {
if (rt) {
return fmt::format_to(ctx.out(), "{{range_tombstone: start={}, end={}, {}}}",
rt.position(), rt.end_position(), rt.tomb);
} else {
return fmt::format_to(ctx.out(), "{{range_tombstone: none}}");
}
}
};

0 comments on commit 4af0a0e

Please sign in to comment.