Add format benchmarks
This commit is contained in:
@@ -254,6 +254,25 @@ inline constexpr int max_decimal_length_v = decltype(term(T{}))::kMaxLength;
|
||||
|
||||
inline constexpr DoubleTerm term(double s) { return DoubleTerm(s); }
|
||||
|
||||
// Runtime string term for std::string_view (works with std::string, const
|
||||
// char*, etc.)
|
||||
struct StringViewTerm {
|
||||
explicit constexpr StringViewTerm(std::string_view s) : s(s) {}
|
||||
static constexpr int kMaxLength =
|
||||
512; // Conservative upper bound for runtime strings
|
||||
void write(char *&buf) const {
|
||||
std::memcpy(buf, s.data(), s.size());
|
||||
buf += s.size();
|
||||
}
|
||||
|
||||
private:
|
||||
std::string_view s;
|
||||
};
|
||||
|
||||
inline constexpr StringViewTerm term(std::string_view s) {
|
||||
return StringViewTerm(s);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user