Skip to content

Commit

Permalink
Remove preprocessor guards for char8_t
Browse files Browse the repository at this point in the history
  • Loading branch information
jimporter committed Aug 1, 2024
1 parent facb519 commit e490b40
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 18 deletions.
2 changes: 0 additions & 2 deletions include/mettle/output/string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,10 @@ namespace mettle {
return s;
}

#if __cpp_char8_t
inline std::string_view
convert_string(const std::u8string_view &s) {
return std::string_view(reinterpret_cast<const char *>(s.data()), s.size());
}
#endif

// Ignore warnings about deprecated <codecvt>.
#if defined(_MSC_VER) && !defined(__clang__)
Expand Down
2 changes: 0 additions & 2 deletions include/mettle/output/to_printable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,9 @@ namespace mettle {
return represent_string(std::wstring(1, c), '\'');
}

#if __cpp_char8_t
inline std::string to_printable(char8_t c) {
return represent_string(std::u8string(1, c), '\'');
}
#endif

inline std::string to_printable(char16_t c) {
return represent_string(std::u16string(1, c), '\'');
Expand Down
2 changes: 0 additions & 2 deletions include/mettle/output/traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ namespace mettle {

template<> struct is_character<char> : std::true_type {};
template<> struct is_character<wchar_t> : std::true_type {};
#if __cpp_char8_t
template<> struct is_character<char8_t> : std::true_type {};
#endif
template<> struct is_character<char16_t> : std::true_type {};
template<> struct is_character<char32_t> : std::true_type {};

Expand Down
12 changes: 2 additions & 10 deletions test/output/test_string_output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@ suite<> test_string_output("string output", [](auto &_) {
});

subsuite<
char,
#if __cpp_char8_t
char8_t,
#endif
wchar_t, char16_t, char32_t
char, char8_t, wchar_t, char16_t, char32_t
>(_, "convert_string()", type_only, [](auto &_) {
using C = fixture_type_t<decltype(_)>;
auto T = &make_string<C>;
Expand All @@ -73,11 +69,7 @@ suite<> test_string_output("string output", [](auto &_) {
});

subsuite<
char,
#if __cpp_char8_t
char8_t,
#endif
wchar_t, char16_t, char32_t
char, char8_t, wchar_t, char16_t, char32_t
>(_, "represent_string()", type_only, [](auto &_) {
using C = fixture_type_t<decltype(_)>;
auto T = &make_string<C>;
Expand Down
2 changes: 0 additions & 2 deletions test/output/test_to_printable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ suite<> test_to_printable("to_printable()", [](auto &_) {
expect(ns, stringified("nullptr"));
});

#if __cpp_char8_t
_.test("char8_t", []() {
expect(u8'x', stringified("'x'"));
expect(u8'\n', stringified("'\\n'"));
Expand All @@ -315,7 +314,6 @@ suite<> test_to_printable("to_printable()", [](auto &_) {
char8_t *ns = nullptr;
expect(ns, stringified("nullptr"));
});
#endif

_.test("char16_t", []() {
expect(u'x', stringified("'x'"));
Expand Down

0 comments on commit e490b40

Please sign in to comment.