Move string_literal to format.h

This commit is contained in:
Victor Zverovich 2024-08-31 07:08:35 -07:00
parent 8a484ad577
commit 53316903e6
2 changed files with 11 additions and 11 deletions

View File

@ -686,17 +686,6 @@ struct has_to_string_view<
T, void_t<decltype(detail::to_string_view(std::declval<T>()))>>
: std::true_type {};
template <typename Char, Char... C> struct string_literal {
static constexpr Char value[sizeof...(C)] = {C...};
constexpr operator basic_string_view<Char>() const {
return {value, sizeof...(C)};
}
};
#if FMT_CPLUSPLUS < 201703L
template <typename Char, Char... C>
constexpr Char string_literal<Char, C...>::value[sizeof...(C)];
#endif
enum class type {
none_type,
// Integer types should go first,

View File

@ -278,6 +278,17 @@ template <typename Char> using std_string_view = std::basic_string_view<Char>;
template <typename T> struct std_string_view {};
#endif
template <typename Char, Char... C> struct string_literal {
static constexpr Char value[sizeof...(C)] = {C...};
constexpr operator basic_string_view<Char>() const {
return {value, sizeof...(C)};
}
};
#if FMT_CPLUSPLUS < 201703L
template <typename Char, Char... C>
constexpr Char string_literal<Char, C...>::value[sizeof...(C)];
#endif
// Implementation of std::bit_cast for pre-C++20.
template <typename To, typename From, FMT_ENABLE_IF(sizeof(To) == sizeof(From))>
FMT_CONSTEXPR20 auto bit_cast(const From& from) -> To {