diff --git a/include/fmt/format.h b/include/fmt/format.h index a5199b67..7af10895 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -566,7 +566,8 @@ class FMT_DEPRECATED u8string_view : public basic_string_view { #if FMT_USE_USER_DEFINED_LITERALS inline namespace literals { -inline basic_string_view operator"" _u(const char* s, std::size_t n) { +FMT_DEPRECATED inline basic_string_view operator"" _u(const char* s, + std::size_t n) { return {reinterpret_cast(s), n}; } } // namespace literals diff --git a/test/format-test.cc b/test/format-test.cc index 070c5033..92ad5369 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -2523,18 +2523,6 @@ std::string from_u8str(const fmt::basic_string_view& str) { return std::string(str.begin(), str.end()); } -#if FMT_USE_USER_DEFINED_LITERALS -TEST(FormatTest, U8StringViewLiteral) { - using namespace fmt::literals; - fmt::basic_string_view s = "ab"_u; - EXPECT_EQ(s.size(), 2u); - const char8_t* data = s.data(); - EXPECT_EQ(char(data[0]), 'a'); - EXPECT_EQ(char(data[1]), 'b'); - EXPECT_EQ(from_u8str(format("{:*^5}"_u, "🤡"_u)), from_u8str("**🤡**"_u)); -} -#endif - TEST(FormatTest, EmphasisNonHeaderOnly) { // Ensure this compiles even if FMT_HEADER_ONLY is not defined. EXPECT_EQ(fmt::format(fmt::emphasis::bold, "bold error"),