1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-09 01:07:16 +01:00
SqMod/vendor/Fmt/include/fmt/compile.h

604 lines
20 KiB
C
Raw Normal View History

2020-09-04 23:02:20 +02:00
// Formatting library for C++ - experimental format string compilation
//
// Copyright (c) 2012 - present, Victor Zverovich and fmt contributors
// All rights reserved.
//
// For the license information refer to format.h.
#ifndef FMT_COMPILE_H_
#define FMT_COMPILE_H_
#include "format.h"
FMT_BEGIN_NAMESPACE
namespace detail {
2021-07-02 20:18:22 +02:00
template <typename Char, typename InputIt>
inline counting_iterator copy_str(InputIt begin, InputIt end,
counting_iterator it) {
return it + (end - begin);
}
2021-03-30 19:32:25 +02:00
template <typename OutputIt> class truncating_iterator_base {
protected:
OutputIt out_;
size_t limit_;
size_t count_ = 0;
truncating_iterator_base() : out_(), limit_(0) {}
truncating_iterator_base(OutputIt out, size_t limit)
: out_(out), limit_(limit) {}
public:
using iterator_category = std::output_iterator_tag;
using value_type = typename std::iterator_traits<OutputIt>::value_type;
using difference_type = std::ptrdiff_t;
using pointer = void;
using reference = void;
using _Unchecked_type =
truncating_iterator_base; // Mark iterator as checked.
OutputIt base() const { return out_; }
size_t count() const { return count_; }
};
// An output iterator that truncates the output and counts the number of objects
// written to it.
template <typename OutputIt,
typename Enable = typename std::is_void<
typename std::iterator_traits<OutputIt>::value_type>::type>
class truncating_iterator;
template <typename OutputIt>
class truncating_iterator<OutputIt, std::false_type>
: public truncating_iterator_base<OutputIt> {
mutable typename truncating_iterator_base<OutputIt>::value_type blackhole_;
public:
using value_type = typename truncating_iterator_base<OutputIt>::value_type;
truncating_iterator() = default;
truncating_iterator(OutputIt out, size_t limit)
: truncating_iterator_base<OutputIt>(out, limit) {}
truncating_iterator& operator++() {
if (this->count_++ < this->limit_) ++this->out_;
return *this;
}
truncating_iterator operator++(int) {
auto it = *this;
++*this;
return it;
}
value_type& operator*() const {
return this->count_ < this->limit_ ? *this->out_ : blackhole_;
}
};
template <typename OutputIt>
class truncating_iterator<OutputIt, std::true_type>
: public truncating_iterator_base<OutputIt> {
public:
truncating_iterator() = default;
truncating_iterator(OutputIt out, size_t limit)
: truncating_iterator_base<OutputIt>(out, limit) {}
template <typename T> truncating_iterator& operator=(T val) {
if (this->count_++ < this->limit_) *this->out_++ = val;
return *this;
}
truncating_iterator& operator++() { return *this; }
truncating_iterator& operator++(int) { return *this; }
truncating_iterator& operator*() { return *this; }
};
2020-09-04 23:02:20 +02:00
// A compile-time string which is compiled into fast formatting code.
class compiled_string {};
template <typename S>
struct is_compiled_string : std::is_base_of<compiled_string, S> {};
/**
\rst
Converts a string literal *s* into a format string that will be parsed at
compile time and converted into efficient formatting code. Requires C++17
``constexpr if`` compiler support.
**Example**::
// Converts 42 into std::string using the most efficient method and no
// runtime format string processing.
std::string s = fmt::format(FMT_COMPILE("{}"), 42);
\endrst
*/
2022-03-16 21:36:44 +01:00
#if defined(__cpp_if_constexpr) && defined(__cpp_return_type_deduction)
2021-07-02 20:18:22 +02:00
# define FMT_COMPILE(s) \
FMT_STRING_IMPL(s, fmt::detail::compiled_string, explicit)
#else
# define FMT_COMPILE(s) FMT_STRING(s)
#endif
2020-09-04 23:02:20 +02:00
2021-03-30 19:32:25 +02:00
#if FMT_USE_NONTYPE_TEMPLATE_PARAMETERS
2021-07-02 20:18:22 +02:00
template <typename Char, size_t N,
fmt::detail_exported::fixed_string<Char, N> Str>
2021-03-30 19:32:25 +02:00
struct udl_compiled_string : compiled_string {
using char_type = Char;
2022-03-16 21:36:44 +01:00
explicit constexpr operator basic_string_view<char_type>() const {
2021-03-30 19:32:25 +02:00
return {Str.data, N - 1};
}
};
#endif
2020-09-04 23:02:20 +02:00
template <typename T, typename... Tail>
const T& first(const T& value, const Tail&...) {
return value;
}
2022-03-16 21:36:44 +01:00
#if defined(__cpp_if_constexpr) && defined(__cpp_return_type_deduction)
2020-09-04 23:02:20 +02:00
template <typename... Args> struct type_list {};
// Returns a reference to the argument at index N from [first, rest...].
template <int N, typename T, typename... Args>
constexpr const auto& get([[maybe_unused]] const T& first,
[[maybe_unused]] const Args&... rest) {
static_assert(N < 1 + sizeof...(Args), "index is out of bounds");
if constexpr (N == 0)
return first;
else
2022-03-16 21:36:44 +01:00
return detail::get<N - 1>(rest...);
2020-09-04 23:02:20 +02:00
}
2021-07-02 20:18:22 +02:00
template <typename Char, typename... Args>
constexpr int get_arg_index_by_name(basic_string_view<Char> name,
type_list<Args...>) {
return get_arg_index_by_name<Args...>(name);
}
2020-09-04 23:02:20 +02:00
template <int N, typename> struct get_type_impl;
template <int N, typename... Args> struct get_type_impl<N, type_list<Args...>> {
2022-03-16 21:36:44 +01:00
using type =
remove_cvref_t<decltype(detail::get<N>(std::declval<Args>()...))>;
2020-09-04 23:02:20 +02:00
};
template <int N, typename T>
using get_type = typename get_type_impl<N, T>::type;
template <typename T> struct is_compiled_format : std::false_type {};
template <typename Char> struct text {
basic_string_view<Char> data;
using char_type = Char;
template <typename OutputIt, typename... Args>
2021-03-30 19:32:25 +02:00
constexpr OutputIt format(OutputIt out, const Args&...) const {
2020-09-04 23:02:20 +02:00
return write<Char>(out, data);
}
};
template <typename Char>
struct is_compiled_format<text<Char>> : std::true_type {};
template <typename Char>
constexpr text<Char> make_text(basic_string_view<Char> s, size_t pos,
size_t size) {
return {{&s[pos], size}};
}
template <typename Char> struct code_unit {
Char value;
using char_type = Char;
template <typename OutputIt, typename... Args>
2021-03-30 19:32:25 +02:00
constexpr OutputIt format(OutputIt out, const Args&...) const {
2020-09-04 23:02:20 +02:00
return write<Char>(out, value);
}
};
2021-07-02 20:18:22 +02:00
// This ensures that the argument type is convertible to `const T&`.
template <typename T, int N, typename... Args>
constexpr const T& get_arg_checked(const Args&... args) {
2022-03-16 21:36:44 +01:00
const auto& arg = detail::get<N>(args...);
2021-07-02 20:18:22 +02:00
if constexpr (detail::is_named_arg<remove_cvref_t<decltype(arg)>>()) {
return arg.value;
} else {
return arg;
}
}
2020-09-04 23:02:20 +02:00
template <typename Char>
struct is_compiled_format<code_unit<Char>> : std::true_type {};
// A replacement field that refers to argument N.
template <typename Char, typename T, int N> struct field {
using char_type = Char;
template <typename OutputIt, typename... Args>
2021-03-30 19:32:25 +02:00
constexpr OutputIt format(OutputIt out, const Args&... args) const {
2021-07-02 20:18:22 +02:00
return write<Char>(out, get_arg_checked<T, N>(args...));
2020-09-04 23:02:20 +02:00
}
};
template <typename Char, typename T, int N>
struct is_compiled_format<field<Char, T, N>> : std::true_type {};
2021-03-30 19:32:25 +02:00
// A replacement field that refers to argument with name.
template <typename Char> struct runtime_named_field {
using char_type = Char;
basic_string_view<Char> name;
template <typename OutputIt, typename T>
constexpr static bool try_format_argument(
OutputIt& out,
// [[maybe_unused]] due to unused-but-set-parameter warning in GCC 7,8,9
[[maybe_unused]] basic_string_view<Char> arg_name, const T& arg) {
if constexpr (is_named_arg<typename std::remove_cv<T>::type>::value) {
if (arg_name == arg.name) {
out = write<Char>(out, arg.value);
return true;
}
}
return false;
}
template <typename OutputIt, typename... Args>
constexpr OutputIt format(OutputIt out, const Args&... args) const {
bool found = (try_format_argument(out, name, args) || ...);
if (!found) {
2021-08-22 19:11:41 +02:00
FMT_THROW(format_error("argument with specified name is not found"));
2021-03-30 19:32:25 +02:00
}
return out;
}
};
template <typename Char>
struct is_compiled_format<runtime_named_field<Char>> : std::true_type {};
2020-09-04 23:02:20 +02:00
// A replacement field that refers to argument N and has format specifiers.
template <typename Char, typename T, int N> struct spec_field {
using char_type = Char;
2021-03-30 19:32:25 +02:00
formatter<T, Char> fmt;
2020-09-04 23:02:20 +02:00
template <typename OutputIt, typename... Args>
2021-07-02 20:18:22 +02:00
constexpr FMT_INLINE OutputIt format(OutputIt out,
const Args&... args) const {
const auto& vargs =
2021-07-02 20:18:22 +02:00
fmt::make_format_args<basic_format_context<OutputIt, Char>>(args...);
2020-09-04 23:02:20 +02:00
basic_format_context<OutputIt, Char> ctx(out, vargs);
2021-07-02 20:18:22 +02:00
return fmt.format(get_arg_checked<T, N>(args...), ctx);
2020-09-04 23:02:20 +02:00
}
};
template <typename Char, typename T, int N>
struct is_compiled_format<spec_field<Char, T, N>> : std::true_type {};
template <typename L, typename R> struct concat {
L lhs;
R rhs;
using char_type = typename L::char_type;
template <typename OutputIt, typename... Args>
2021-03-30 19:32:25 +02:00
constexpr OutputIt format(OutputIt out, const Args&... args) const {
2020-09-04 23:02:20 +02:00
out = lhs.format(out, args...);
return rhs.format(out, args...);
}
};
template <typename L, typename R>
struct is_compiled_format<concat<L, R>> : std::true_type {};
template <typename L, typename R>
constexpr concat<L, R> make_concat(L lhs, R rhs) {
return {lhs, rhs};
}
struct unknown_format {};
template <typename Char>
constexpr size_t parse_text(basic_string_view<Char> str, size_t pos) {
for (size_t size = str.size(); pos != size; ++pos) {
if (str[pos] == '{' || str[pos] == '}') break;
}
return pos;
}
template <typename Args, size_t POS, int ID, typename S>
constexpr auto compile_format_string(S format_str);
template <typename Args, size_t POS, int ID, typename T, typename S>
constexpr auto parse_tail(T head, S format_str) {
if constexpr (POS !=
basic_string_view<typename S::char_type>(format_str).size()) {
constexpr auto tail = compile_format_string<Args, POS, ID>(format_str);
if constexpr (std::is_same<remove_cvref_t<decltype(tail)>,
unknown_format>())
return tail;
else
return make_concat(head, tail);
} else {
return head;
}
}
template <typename T, typename Char> struct parse_specs_result {
formatter<T, Char> fmt;
size_t end;
int next_arg_id;
};
2021-03-30 19:32:25 +02:00
constexpr int manual_indexing_id = -1;
2020-09-04 23:02:20 +02:00
template <typename T, typename Char>
constexpr parse_specs_result<T, Char> parse_specs(basic_string_view<Char> str,
2021-03-30 19:32:25 +02:00
size_t pos, int next_arg_id) {
2020-09-04 23:02:20 +02:00
str.remove_prefix(pos);
2021-03-30 19:32:25 +02:00
auto ctx = basic_format_parse_context<Char>(str, {}, next_arg_id);
2020-09-04 23:02:20 +02:00
auto f = formatter<T, Char>();
auto end = f.parse(ctx);
2021-03-30 19:32:25 +02:00
return {f, pos + fmt::detail::to_unsigned(end - str.data()) + 1,
next_arg_id == 0 ? manual_indexing_id : ctx.next_arg_id()};
}
template <typename Char> struct arg_id_handler {
2021-07-02 20:18:22 +02:00
arg_ref<Char> arg_id;
2021-03-30 19:32:25 +02:00
2021-07-02 20:18:22 +02:00
constexpr int operator()() {
2021-03-30 19:32:25 +02:00
FMT_ASSERT(false, "handler cannot be used with automatic indexing");
return 0;
}
2021-07-02 20:18:22 +02:00
constexpr int operator()(int id) {
2021-03-30 19:32:25 +02:00
arg_id = arg_ref<Char>(id);
return 0;
}
2021-07-02 20:18:22 +02:00
constexpr int operator()(basic_string_view<Char> id) {
2021-03-30 19:32:25 +02:00
arg_id = arg_ref<Char>(id);
return 0;
}
2022-03-16 21:36:44 +01:00
constexpr void on_error(const char* message) {
FMT_THROW(format_error(message));
}
2021-03-30 19:32:25 +02:00
};
template <typename Char> struct parse_arg_id_result {
arg_ref<Char> arg_id;
const Char* arg_id_end;
};
template <int ID, typename Char>
constexpr auto parse_arg_id(const Char* begin, const Char* end) {
auto handler = arg_id_handler<Char>{arg_ref<Char>{}};
2021-07-02 20:18:22 +02:00
auto arg_id_end = parse_arg_id(begin, end, handler);
2021-03-30 19:32:25 +02:00
return parse_arg_id_result<Char>{handler.arg_id, arg_id_end};
2020-09-04 23:02:20 +02:00
}
2021-07-02 20:18:22 +02:00
template <typename T, typename Enable = void> struct field_type {
using type = remove_cvref_t<T>;
};
template <typename T>
struct field_type<T, enable_if_t<detail::is_named_arg<T>::value>> {
using type = remove_cvref_t<decltype(T::value)>;
};
template <typename T, typename Args, size_t END_POS, int ARG_INDEX, int NEXT_ID,
typename S>
constexpr auto parse_replacement_field_then_tail(S format_str) {
using char_type = typename S::char_type;
constexpr auto str = basic_string_view<char_type>(format_str);
constexpr char_type c = END_POS != str.size() ? str[END_POS] : char_type();
if constexpr (c == '}') {
return parse_tail<Args, END_POS + 1, NEXT_ID>(
field<char_type, typename field_type<T>::type, ARG_INDEX>(),
format_str);
} else if constexpr (c == ':') {
constexpr auto result = parse_specs<typename field_type<T>::type>(
str, END_POS + 1, NEXT_ID == manual_indexing_id ? 0 : NEXT_ID);
return parse_tail<Args, result.end, result.next_arg_id>(
spec_field<char_type, typename field_type<T>::type, ARG_INDEX>{
result.fmt},
format_str);
}
}
2020-09-04 23:02:20 +02:00
// Compiles a non-empty format string and returns the compiled representation
// or unknown_format() on unrecognized input.
template <typename Args, size_t POS, int ID, typename S>
constexpr auto compile_format_string(S format_str) {
using char_type = typename S::char_type;
2021-07-02 20:18:22 +02:00
constexpr auto str = basic_string_view<char_type>(format_str);
2020-09-04 23:02:20 +02:00
if constexpr (str[POS] == '{') {
2021-03-30 19:32:25 +02:00
if constexpr (POS + 1 == str.size())
2021-08-22 19:11:41 +02:00
FMT_THROW(format_error("unmatched '{' in format string"));
2020-09-04 23:02:20 +02:00
if constexpr (str[POS + 1] == '{') {
return parse_tail<Args, POS + 2, ID>(make_text(str, POS, 1), format_str);
2021-03-30 19:32:25 +02:00
} else if constexpr (str[POS + 1] == '}' || str[POS + 1] == ':') {
static_assert(ID != manual_indexing_id,
"cannot switch from manual to automatic argument indexing");
2021-07-02 20:18:22 +02:00
constexpr auto next_id =
ID != manual_indexing_id ? ID + 1 : manual_indexing_id;
return parse_replacement_field_then_tail<get_type<ID, Args>, Args,
POS + 1, ID, next_id>(
format_str);
2020-09-04 23:02:20 +02:00
} else {
2021-03-30 19:32:25 +02:00
constexpr auto arg_id_result =
parse_arg_id<ID>(str.data() + POS + 1, str.data() + str.size());
constexpr auto arg_id_end_pos = arg_id_result.arg_id_end - str.data();
constexpr char_type c =
arg_id_end_pos != str.size() ? str[arg_id_end_pos] : char_type();
static_assert(c == '}' || c == ':', "missing '}' in format string");
if constexpr (arg_id_result.arg_id.kind == arg_id_kind::index) {
static_assert(
ID == manual_indexing_id || ID == 0,
"cannot switch from automatic to manual argument indexing");
constexpr auto arg_index = arg_id_result.arg_id.val.index;
2021-07-02 20:18:22 +02:00
return parse_replacement_field_then_tail<get_type<arg_index, Args>,
Args, arg_id_end_pos,
arg_index, manual_indexing_id>(
format_str);
2021-03-30 19:32:25 +02:00
} else if constexpr (arg_id_result.arg_id.kind == arg_id_kind::name) {
2021-07-02 20:18:22 +02:00
constexpr auto arg_index =
get_arg_index_by_name(arg_id_result.arg_id.val.name, Args{});
if constexpr (arg_index != invalid_arg_index) {
constexpr auto next_id =
ID != manual_indexing_id ? ID + 1 : manual_indexing_id;
return parse_replacement_field_then_tail<
decltype(get_type<arg_index, Args>::value), Args, arg_id_end_pos,
arg_index, next_id>(format_str);
} else {
if constexpr (c == '}') {
return parse_tail<Args, arg_id_end_pos + 1, ID>(
runtime_named_field<char_type>{arg_id_result.arg_id.val.name},
format_str);
} else if constexpr (c == ':') {
return unknown_format(); // no type info for specs parsing
}
2021-03-30 19:32:25 +02:00
}
}
2020-09-04 23:02:20 +02:00
}
} else if constexpr (str[POS] == '}') {
2021-03-30 19:32:25 +02:00
if constexpr (POS + 1 == str.size())
2021-08-22 19:11:41 +02:00
FMT_THROW(format_error("unmatched '}' in format string"));
2020-09-04 23:02:20 +02:00
return parse_tail<Args, POS + 2, ID>(make_text(str, POS, 1), format_str);
} else {
constexpr auto end = parse_text(str, POS + 1);
if constexpr (end - POS > 1) {
return parse_tail<Args, end, ID>(make_text(str, POS, end - POS),
format_str);
} else {
return parse_tail<Args, end, ID>(code_unit<char_type>{str[POS]},
format_str);
}
}
}
template <typename... Args, typename S,
2021-07-02 20:18:22 +02:00
FMT_ENABLE_IF(detail::is_compiled_string<S>::value)>
2020-09-04 23:02:20 +02:00
constexpr auto compile(S format_str) {
2021-07-02 20:18:22 +02:00
constexpr auto str = basic_string_view<typename S::char_type>(format_str);
2020-09-04 23:02:20 +02:00
if constexpr (str.size() == 0) {
return detail::make_text(str, 0, 0);
} else {
constexpr auto result =
detail::compile_format_string<detail::type_list<Args...>, 0, 0>(
format_str);
2021-03-30 19:32:25 +02:00
return result;
2020-09-04 23:02:20 +02:00
}
}
2022-03-16 21:36:44 +01:00
#endif // defined(__cpp_if_constexpr) && defined(__cpp_return_type_deduction)
2020-09-04 23:02:20 +02:00
} // namespace detail
2021-07-02 20:18:22 +02:00
FMT_MODULE_EXPORT_BEGIN
2020-09-04 23:02:20 +02:00
2022-03-16 21:36:44 +01:00
#if defined(__cpp_if_constexpr) && defined(__cpp_return_type_deduction)
2020-09-04 23:02:20 +02:00
template <typename CompiledFormat, typename... Args,
typename Char = typename CompiledFormat::char_type,
FMT_ENABLE_IF(detail::is_compiled_format<CompiledFormat>::value)>
FMT_INLINE std::basic_string<Char> format(const CompiledFormat& cf,
const Args&... args) {
2021-07-02 20:18:22 +02:00
auto s = std::basic_string<Char>();
cf.format(std::back_inserter(s), args...);
return s;
2020-09-04 23:02:20 +02:00
}
template <typename OutputIt, typename CompiledFormat, typename... Args,
FMT_ENABLE_IF(detail::is_compiled_format<CompiledFormat>::value)>
2021-07-02 20:18:22 +02:00
constexpr FMT_INLINE OutputIt format_to(OutputIt out, const CompiledFormat& cf,
const Args&... args) {
2020-09-04 23:02:20 +02:00
return cf.format(out, args...);
}
template <typename S, typename... Args,
FMT_ENABLE_IF(detail::is_compiled_string<S>::value)>
FMT_INLINE std::basic_string<typename S::char_type> format(const S&,
Args&&... args) {
if constexpr (std::is_same<typename S::char_type, char>::value) {
2021-07-02 20:18:22 +02:00
constexpr auto str = basic_string_view<typename S::char_type>(S());
2021-03-30 19:32:25 +02:00
if constexpr (str.size() == 2 && str[0] == '{' && str[1] == '}') {
const auto& first = detail::first(args...);
if constexpr (detail::is_named_arg<
remove_cvref_t<decltype(first)>>::value) {
return fmt::to_string(first.value);
} else {
return fmt::to_string(first);
}
}
}
2020-09-04 23:02:20 +02:00
constexpr auto compiled = detail::compile<Args...>(S());
2021-03-30 19:32:25 +02:00
if constexpr (std::is_same<remove_cvref_t<decltype(compiled)>,
detail::unknown_format>()) {
2022-03-16 21:36:44 +01:00
return fmt::format(
static_cast<basic_string_view<typename S::char_type>>(S()),
std::forward<Args>(args)...);
2021-03-30 19:32:25 +02:00
} else {
2022-03-16 21:36:44 +01:00
return fmt::format(compiled, std::forward<Args>(args)...);
2021-03-30 19:32:25 +02:00
}
2020-09-04 23:02:20 +02:00
}
template <typename OutputIt, typename S, typename... Args,
FMT_ENABLE_IF(detail::is_compiled_string<S>::value)>
2021-03-30 19:32:25 +02:00
FMT_CONSTEXPR OutputIt format_to(OutputIt out, const S&, Args&&... args) {
2020-09-04 23:02:20 +02:00
constexpr auto compiled = detail::compile<Args...>(S());
2021-03-30 19:32:25 +02:00
if constexpr (std::is_same<remove_cvref_t<decltype(compiled)>,
detail::unknown_format>()) {
2022-03-16 21:36:44 +01:00
return fmt::format_to(
out, static_cast<basic_string_view<typename S::char_type>>(S()),
std::forward<Args>(args)...);
2021-03-30 19:32:25 +02:00
} else {
2022-03-16 21:36:44 +01:00
return fmt::format_to(out, compiled, std::forward<Args>(args)...);
2021-03-30 19:32:25 +02:00
}
2020-09-04 23:02:20 +02:00
}
2021-07-02 20:18:22 +02:00
#endif
2020-09-04 23:02:20 +02:00
template <typename OutputIt, typename S, typename... Args,
FMT_ENABLE_IF(detail::is_compiled_string<S>::value)>
2021-07-02 20:18:22 +02:00
format_to_n_result<OutputIt> format_to_n(OutputIt out, size_t n,
const S& format_str, Args&&... args) {
2022-03-16 21:36:44 +01:00
auto it = fmt::format_to(detail::truncating_iterator<OutputIt>(out, n),
format_str, std::forward<Args>(args)...);
return {it.base(), it.count()};
}
2021-07-02 20:18:22 +02:00
template <typename S, typename... Args,
FMT_ENABLE_IF(detail::is_compiled_string<S>::value)>
size_t formatted_size(const S& format_str, const Args&... args) {
2022-03-16 21:36:44 +01:00
return fmt::format_to(detail::counting_iterator(), format_str, args...)
.count();
2021-07-02 20:18:22 +02:00
}
template <typename S, typename... Args,
FMT_ENABLE_IF(detail::is_compiled_string<S>::value)>
void print(std::FILE* f, const S& format_str, const Args&... args) {
memory_buffer buffer;
2022-03-16 21:36:44 +01:00
fmt::format_to(std::back_inserter(buffer), format_str, args...);
2021-07-02 20:18:22 +02:00
detail::print(f, {buffer.data(), buffer.size()});
}
template <typename S, typename... Args,
FMT_ENABLE_IF(detail::is_compiled_string<S>::value)>
void print(const S& format_str, const Args&... args) {
print(stdout, format_str, args...);
2020-09-04 23:02:20 +02:00
}
2021-03-30 19:32:25 +02:00
#if FMT_USE_NONTYPE_TEMPLATE_PARAMETERS
inline namespace literals {
2022-03-16 21:36:44 +01:00
template <detail_exported::fixed_string Str> constexpr auto operator""_cf() {
using char_t = remove_cvref_t<decltype(Str.data[0])>;
return detail::udl_compiled_string<char_t, sizeof(Str.data) / sizeof(char_t),
Str>();
2021-03-30 19:32:25 +02:00
}
} // namespace literals
#endif
2021-07-02 20:18:22 +02:00
FMT_MODULE_EXPORT_END
2020-09-04 23:02:20 +02:00
FMT_END_NAMESPACE
#endif // FMT_COMPILE_H_