Cleanup check_format_string

This commit is contained in:
Victor Zverovich 2022-05-29 19:00:22 -07:00
parent 054b1d9808
commit fe6eb792d5
2 changed files with 10 additions and 15 deletions

View File

@ -322,8 +322,6 @@ Utilities
.. doxygenfunction:: fmt::to_string(const T &value) -> std::string
.. doxygenfunction:: fmt::to_string_view(const Char *s) -> basic_string_view<Char>
.. doxygenfunction:: fmt::join(Range &&range, string_view sep) -> join_view<detail::iterator_t<Range>, detail::sentinel_t<Range>>
.. doxygenfunction:: fmt::join(It begin, Sentinel end, string_view sep) -> join_view<It, Sentinel>

View File

@ -546,18 +546,6 @@ template <typename S> struct char_t_impl<S, enable_if_t<is_string<S>::value>> {
using type = typename result::value_type;
};
// Reports a compile-time error if S is not a valid format string.
template <typename..., typename S, FMT_ENABLE_IF(!is_compile_string<S>::value)>
FMT_INLINE void check_format_string(const S&) {
#ifdef FMT_ENFORCE_COMPILE_STRING
static_assert(is_compile_string<S>::value,
"FMT_ENFORCE_COMPILE_STRING requires all format strings to use "
"FMT_STRING.");
#endif
}
template <typename..., typename S, FMT_ENABLE_IF(is_compile_string<S>::value)>
void check_format_string(S);
FMT_NORETURN FMT_API void throw_format_error(const char* message);
struct error_handler {
@ -2921,8 +2909,17 @@ class format_string_checker {
}
};
// Reports a compile-time error if S is not a valid format string.
template <typename..., typename S, FMT_ENABLE_IF(!is_compile_string<S>::value)>
FMT_INLINE void check_format_string(const S&) {
#ifdef FMT_ENFORCE_COMPILE_STRING
static_assert(is_compile_string<S>::value,
"FMT_ENFORCE_COMPILE_STRING requires all format strings to use "
"FMT_STRING.");
#endif
}
template <typename... Args, typename S,
enable_if_t<(is_compile_string<S>::value), int>>
FMT_ENABLE_IF(is_compile_string<S>::value)>
void check_format_string(S format_str) {
FMT_CONSTEXPR auto s = to_string_view(format_str);
using checker = format_string_checker<typename S::char_type, error_handler,