Skip to content

Commit abf79a4

Browse files
Move the implementation of array formatter to source file to reduce c… (#572)
* Move the implementation of array formatter to source file to reduce compilation time * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 6f0642e commit abf79a4

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

include/sparrow/array.hpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,10 @@ struct std::formatter<sparrow::array>
112112
return ctx.begin(); // Simple implementation
113113
}
114114

115-
auto format(const sparrow::array& ar, std::format_context& ctx) const
116-
{
117-
return ar.visit(
118-
[&ctx](const auto& layout)
119-
{
120-
return std::format_to(ctx.out(), "{}", layout);
121-
}
122-
);
123-
}
115+
using iterator = std::format_context::iterator;
116+
117+
SPARROW_API
118+
iterator format(const sparrow::array& ar, std::format_context& ctx) const;
124119
};
125120

126121
namespace sparrow

src/array.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,14 @@ namespace sparrow
154154
);
155155
}
156156
}
157+
#if defined(__cpp_lib_format)
158+
auto std::formatter<sparrow::array>::format(const sparrow::array& ar, std::format_context& ctx) const -> iterator
159+
{
160+
return ar.visit(
161+
[&ctx](const auto& layout)
162+
{
163+
return std::format_to(ctx.out(), "{}", layout);
164+
}
165+
);
166+
}
167+
#endif

0 commit comments

Comments
 (0)