move fixed_string from compile.h to format.h

This commit is contained in:
Alexey Ochapov 2021-04-18 08:06:22 +03:00 committed by Victor Zverovich
parent bb006f9735
commit fc56af14c2
2 changed files with 22 additions and 17 deletions

View File

@ -13,15 +13,6 @@
#include "format.h"
#ifndef FMT_USE_NONTYPE_TEMPLATE_PARAMETERS
# if defined(__cpp_nontype_template_parameter_class) && \
(!FMT_GCC_VERSION || FMT_GCC_VERSION >= 903)
# define FMT_USE_NONTYPE_TEMPLATE_PARAMETERS 1
# else
# define FMT_USE_NONTYPE_TEMPLATE_PARAMETERS 0
# endif
#endif
FMT_BEGIN_NAMESPACE
namespace detail {
@ -126,14 +117,6 @@ struct is_compiled_string : std::is_base_of<compiled_string, S> {};
#define FMT_COMPILE(s) FMT_STRING_IMPL(s, fmt::detail::compiled_string)
#if FMT_USE_NONTYPE_TEMPLATE_PARAMETERS
template <typename Char, size_t N> struct fixed_string {
constexpr fixed_string(const Char (&str)[N]) {
copy_str<Char, const Char*, Char*>(static_cast<const Char*>(str), str + N,
data);
}
Char data[N]{};
};
template <typename Char, size_t N, fixed_string<Char, N> Str>
struct udl_compiled_string : compiled_string {
using char_type = Char;

View File

@ -263,6 +263,15 @@ inline int ctzll(uint64_t x) {
FMT_END_NAMESPACE
#endif
#ifndef FMT_USE_NONTYPE_TEMPLATE_PARAMETERS
# if defined(__cpp_nontype_template_parameter_class) && \
(!FMT_GCC_VERSION || FMT_GCC_VERSION >= 903)
# define FMT_USE_NONTYPE_TEMPLATE_PARAMETERS 1
# else
# define FMT_USE_NONTYPE_TEMPLATE_PARAMETERS 0
# endif
#endif
FMT_BEGIN_NAMESPACE
namespace detail {
@ -3908,6 +3917,19 @@ void vprint(basic_string_view<Char> format_str, wformat_args args) {
}
FMT_MODULE_EXPORT_END
#if FMT_USE_NONTYPE_TEMPLATE_PARAMETERS
namespace detail {
template <typename Char, size_t N> struct fixed_string {
constexpr fixed_string(const Char (&str)[N]) {
copy_str<Char, const Char*, Char*>(static_cast<const Char*>(str), str + N,
data);
}
Char data[N]{};
};
} // namespace detail
#endif
#if FMT_USE_USER_DEFINED_LITERALS
namespace detail {
template <typename Char> struct udl_formatter {