Skip to content

Commit

Permalink
Move char8_t to fmt/core.h
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Jun 8, 2019
1 parent 4faadff commit 5d9100f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
9 changes: 7 additions & 2 deletions include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,16 @@ template <typename Char> class basic_string_view {
using string_view = basic_string_view<char>;
using wstring_view = basic_string_view<wchar_t>;

#ifndef __cpp_char8_t
// A UTF-8 code unit type.
enum char8_t : unsigned char {};
#endif

/** Specifies if ``T`` is a character type. Can be specialized by users. */
template <typename T> struct is_char : std::false_type {};
template <> struct is_char<char> : std::true_type {};
template <> struct is_char<wchar_t> : std::true_type {};
template <> struct is_char<char8_t> : std::true_type {};
template <> struct is_char<char16_t> : std::true_type {};
template <> struct is_char<char32_t> : std::true_type {};

Expand Down Expand Up @@ -719,7 +725,7 @@ template <typename Context> class value {
// Get the formatter type through the context to allow different contexts
// have different extension points, e.g. `formatter<T>` for `format` and
// `printf_formatter<T>` for `printf`.
custom.format = &format_custom_arg<
custom.format = format_custom_arg<
T, conditional_t<has_formatter<T, Context>::value,
typename Context::template formatter_type<T>,
internal::fallback_formatter<T, char_type>>>;
Expand Down Expand Up @@ -1030,7 +1036,6 @@ template <typename Context> class arg_map {
class locale_ref {
private:
const void* locale_; // A type-erased pointer to std::locale.
friend class locale;

public:
locale_ref() : locale_(nullptr) {}
Expand Down
8 changes: 0 additions & 8 deletions include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -394,14 +394,6 @@ void buffer<T>::append(const U* begin, const U* end) {
}
} // namespace internal

// C++20 feature test, since r346892 Clang considers char8_t a fundamental
// type in this mode. If this is the case __cpp_char8_t will be defined.
#if !defined(__cpp_char8_t)
// A UTF-8 code unit type.
enum char8_t : unsigned char {};
#endif
template <> struct is_char<char8_t> : std::true_type {};

// A UTF-8 string view.
class u8string_view : public basic_string_view<char8_t> {
public:
Expand Down

0 comments on commit 5d9100f

Please sign in to comment.