Export compiled_string so that user can customize one (#3999)

This commit is contained in:
LoveSy
2024-06-10 01:58:58 +08:00
committed by GitHub
parent d1cab6a9ae
commit fad0222a0c

View File

@ -15,6 +15,10 @@
#include "format.h" #include "format.h"
FMT_BEGIN_NAMESPACE FMT_BEGIN_NAMESPACE
// A compile-time string which is compiled into fast formatting code.
FMT_EXPORT class compiled_string {};
namespace detail { namespace detail {
template <typename T, typename InputIt> template <typename T, typename InputIt>
@ -23,9 +27,6 @@ FMT_CONSTEXPR inline auto copy(InputIt begin, InputIt end, counting_iterator it)
return it + (end - begin); return it + (end - begin);
} }
// A compile-time string which is compiled into fast formatting code.
class compiled_string {};
template <typename S> template <typename S>
struct is_compiled_string : std::is_base_of<compiled_string, S> {}; struct is_compiled_string : std::is_base_of<compiled_string, S> {};
@ -41,8 +42,7 @@ struct is_compiled_string : std::is_base_of<compiled_string, S> {};
* std::string s = fmt::format(FMT_COMPILE("{}"), 42); * std::string s = fmt::format(FMT_COMPILE("{}"), 42);
*/ */
#if defined(__cpp_if_constexpr) && defined(__cpp_return_type_deduction) #if defined(__cpp_if_constexpr) && defined(__cpp_return_type_deduction)
# define FMT_COMPILE(s) \ # define FMT_COMPILE(s) FMT_STRING_IMPL(s, fmt::compiled_string, explicit)
FMT_STRING_IMPL(s, fmt::detail::compiled_string, explicit)
#else #else
# define FMT_COMPILE(s) FMT_STRING(s) # define FMT_COMPILE(s) FMT_STRING(s)
#endif #endif