Skip to content

Commit ce37966

Browse files
committed
fix clang
1 parent 3846d96 commit ce37966

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/iceberg/type.cc

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,14 @@ ListType::ListType(int32_t field_id, std::shared_ptr<Type> type, bool optional)
151151
: element_(field_id, std::string(kElementName), std::move(type), optional) {}
152152

153153
TypeId ListType::type_id() const { return TypeId::kList; }
154-
std::string ListType::ToString() const { return std::format("list<{}>", element_); }
154+
std::string ListType::ToString() const {
155+
// XXX: work around Clang/libc++: "<{}>" in a format string appears to get
156+
// parsed as {<>} or something; split up the format string to avoid that
157+
std::string repr = "list<";
158+
std::format_to(std::back_inserter(repr), "{}", element_);
159+
repr += ">";
160+
return repr;
161+
}
155162
std::span<const SchemaField> ListType::fields() const { return {&element_, 1}; }
156163
std::optional<std::reference_wrapper<const SchemaField>> ListType::GetFieldById(
157164
int32_t field_id) const {
@@ -200,7 +207,13 @@ const SchemaField& MapType::key() const { return fields_[0]; }
200207
const SchemaField& MapType::value() const { return fields_[1]; }
201208
TypeId MapType::type_id() const { return TypeId::kMap; }
202209
std::string MapType::ToString() const {
203-
return std::format("map<{}: {}>", key(), value());
210+
// XXX: work around Clang/libc++: "<{}>" in a format string appears to get
211+
// parsed as {<>} or something; split up the format string to avoid that
212+
std::string repr = "map<";
213+
214+
std::format_to(std::back_inserter(repr), "{}: {}", key(), value());
215+
repr += "}";
216+
return repr;
204217
}
205218
std::span<const SchemaField> MapType::fields() const { return fields_; }
206219
std::optional<std::reference_wrapper<const SchemaField>> MapType::GetFieldById(

src/iceberg/util/formatter.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@
3333
#include "iceberg/util/formattable.h"
3434

3535
/// \brief Make all classes deriving from iceberg::util::Formattable
36-
/// formattable with std::format.
36+
/// formattable with std::format.
3737
template <std::derived_from<iceberg::util::Formattable> Derived>
3838
struct std::formatter<Derived> : std::formatter<std::string_view> {
39-
auto format(const iceberg::util::Formattable& obj, std::format_context& ctx) const {
39+
template <class FormatContext>
40+
auto format(const iceberg::util::Formattable& obj, FormatContext& ctx) const {
4041
return std::formatter<string_view>::format(obj.ToString(), ctx);
4142
}
4243
};

0 commit comments

Comments
 (0)