mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-29 18:27:40 +02:00
Simplify implementation of operator""_cf
(#4349)
This commit is contained in:
committed by
GitHub
parent
0ca42e836e
commit
94ab51cb8c
@ -41,16 +41,6 @@ namespace detail {
|
|||||||
# define FMT_COMPILE(s) FMT_STRING(s)
|
# define FMT_COMPILE(s) FMT_STRING(s)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if FMT_USE_NONTYPE_TEMPLATE_ARGS
|
|
||||||
template <typename Char, size_t N, fmt::detail::fixed_string<Char, N> Str>
|
|
||||||
struct udl_compiled_string : compiled_string {
|
|
||||||
using char_type = Char;
|
|
||||||
constexpr explicit operator basic_string_view<char_type>() const {
|
|
||||||
return {Str.data, N - 1};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template <typename T, typename... Tail>
|
template <typename T, typename... Tail>
|
||||||
auto first(const T& value, const Tail&...) -> const T& {
|
auto first(const T& value, const Tail&...) -> const T& {
|
||||||
return value;
|
return value;
|
||||||
@ -538,9 +528,7 @@ void print(const S& fmt, const Args&... args) {
|
|||||||
#if FMT_USE_NONTYPE_TEMPLATE_ARGS
|
#if FMT_USE_NONTYPE_TEMPLATE_ARGS
|
||||||
inline namespace literals {
|
inline namespace literals {
|
||||||
template <detail::fixed_string Str> constexpr auto operator""_cf() {
|
template <detail::fixed_string Str> constexpr auto operator""_cf() {
|
||||||
using char_t = remove_cvref_t<decltype(Str.data[0])>;
|
return FMT_COMPILE(Str.data);
|
||||||
return detail::udl_compiled_string<char_t, sizeof(Str.data) / sizeof(char_t),
|
|
||||||
Str>();
|
|
||||||
}
|
}
|
||||||
} // namespace literals
|
} // namespace literals
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user