]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw: specialize fmt::formatter<> for rgw_obj_key
authorKefu Chai <tchaikov@gmail.com>
Fri, 2 Dec 2022 09:23:23 +0000 (17:23 +0800)
committerKefu Chai <tchaikov@gmail.com>
Sat, 10 Dec 2022 01:58:01 +0000 (09:58 +0800)
since fmt v9, fmt::formatter<> is not specialized for the types with
operator<<(ostream&, ...) anymore. so we need to specialize it manually.
in this change, fmt::formatter<rgw_obj_key> is defined so the tree can
compile with fmt v9.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
src/rgw/rgw_obj_types.h

index 781150b8becdaadf2b959438674449c21f84fcba..c90d450793c7b7498d8ca5bfdd03532fd1051b81 100644 (file)
@@ -397,6 +397,13 @@ inline std::ostream& operator<<(std::ostream& out, const rgw_obj_key &o) {
   return out << o.to_str();
 }
 
+template<> struct fmt::formatter<rgw_obj_key> : fmt::formatter<std::string_view> {
+  template <typename FormatContext>
+  auto format(const rgw_obj_key& key, FormatContext& ctx) const {
+    return formatter<std::string_view>::format(key.to_str(), ctx);
+  }
+};
+
 struct rgw_raw_obj {
   rgw_pool pool;
   std::string oid;