wgtmac commented on code in PR #86:
URL: https://github.com/apache/iceberg-cpp/pull/86#discussion_r2055639146


##########
src/iceberg/util/formatter.h:
##########
@@ -40,3 +43,102 @@ struct std::formatter<Derived> : 
std::formatter<std::string_view> {
     return std::formatter<string_view>::format(obj.ToString(), ctx);
   }
 };
+
+/// \brief std::formatter specialization for std::vector
+template <typename T>
+struct std::formatter<std::vector<T>> : std::formatter<std::string_view> {
+  template <class FormatContext>
+  auto format(const std::vector<T>& vec, FormatContext& ctx) const {
+    std::string result = "[";
+
+    bool first = true;
+    for (const auto& item : vec) {
+      if (!first) {
+        std::format_to(std::back_inserter(result), ", ");
+      }
+      if constexpr (requires { *item; }) {
+        if (item) {
+          std::format_to(std::back_inserter(result), "{}", *item);
+        } else {
+          std::format_to(std::back_inserter(result), "null");
+        }
+      } else {
+        std::format_to(std::back_inserter(result), "{}", item);
+      }
+      first = false;
+    }
+
+    std::format_to(std::back_inserter(result), "]");
+    return std::formatter<std::string_view>::format(result, ctx);
+  }
+};
+
+/// \brief Helper template for formatting map-like containers
+template <typename MapType>
+std::string FormatMap(const MapType& map) {
+  std::string result = "{";
+
+  bool first = true;
+  for (const auto& [key, value] : map) {
+    if (!first) {
+      std::format_to(std::back_inserter(result), ", ");
+    }
+
+    // Format key (handle if it's a smart pointer)
+    if constexpr (requires { *key; }) {

Review Comment:
   I've modified the concept to strictly check smart pointer type.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to