mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-25 06:21:00 +00:00
Deprecate u8string_view
This commit is contained in:
parent
5390e29d42
commit
dea7fde8b7
@ -1535,7 +1535,8 @@ inline void print(std::FILE* f, const S& format_str, Args&&... args) {
|
||||
|
||||
/**
|
||||
\rst
|
||||
Prints formatted data to ``stdout``.
|
||||
Formats ``args`` according to specifications in ``format_str`` and writes the
|
||||
output to ``stdout``.
|
||||
|
||||
**Example**::
|
||||
|
||||
|
@ -559,8 +559,7 @@ class buffer_range : public internal::output_range<
|
||||
: internal::output_range<iterator, T>(std::back_inserter(buf)) {}
|
||||
};
|
||||
|
||||
// A UTF-8 string view.
|
||||
class u8string_view : public basic_string_view<char8_t> {
|
||||
class FMT_DEPRECATED u8string_view : public basic_string_view<char8_t> {
|
||||
public:
|
||||
u8string_view(const char* s)
|
||||
: basic_string_view<char8_t>(reinterpret_cast<const char8_t*>(s)) {}
|
||||
@ -571,8 +570,8 @@ class u8string_view : public basic_string_view<char8_t> {
|
||||
|
||||
#if FMT_USE_USER_DEFINED_LITERALS
|
||||
inline namespace literals {
|
||||
inline u8string_view operator"" _u(const char* s, std::size_t n) {
|
||||
return {s, n};
|
||||
inline basic_string_view<char8_t> operator"" _u(const char* s, std::size_t n) {
|
||||
return {reinterpret_cast<const char8_t*>(s), n};
|
||||
}
|
||||
} // namespace literals
|
||||
#endif
|
||||
|
@ -427,7 +427,11 @@ TEST(FormatTest, FormatErrorCode) {
|
||||
}
|
||||
|
||||
TEST(FormatTest, CountCodePoints) {
|
||||
EXPECT_EQ(4, fmt::internal::count_code_points(fmt::u8string_view("ёжик")));
|
||||
#ifndef __cpp_char8_t
|
||||
using fmt::char8_t;
|
||||
#endif
|
||||
EXPECT_EQ(4, fmt::internal::count_code_points(
|
||||
fmt::basic_string_view<char8_t>(reinterpret_cast<const char8_t*>("ёжик"))));
|
||||
}
|
||||
|
||||
// Tests fmt::internal::count_digits for integer type Int.
|
||||
|
@ -2467,27 +2467,10 @@ TEST(FormatTest, FmtStringInTemplate) {
|
||||
using fmt::char8_t;
|
||||
#endif
|
||||
|
||||
TEST(FormatTest, ConstructU8StringViewFromCString) {
|
||||
fmt::u8string_view s("ab");
|
||||
EXPECT_EQ(s.size(), 2u);
|
||||
const char8_t* data = s.data();
|
||||
EXPECT_EQ(data[0], 'a');
|
||||
EXPECT_EQ(data[1], 'b');
|
||||
}
|
||||
|
||||
TEST(FormatTest, ConstructU8StringViewFromDataAndSize) {
|
||||
fmt::u8string_view s("foobar", 3);
|
||||
EXPECT_EQ(s.size(), 3u);
|
||||
const char8_t* data = s.data();
|
||||
EXPECT_EQ(data[0], 'f');
|
||||
EXPECT_EQ(data[1], 'o');
|
||||
EXPECT_EQ(data[2], 'o');
|
||||
}
|
||||
|
||||
#if FMT_USE_USER_DEFINED_LITERALS
|
||||
TEST(FormatTest, U8StringViewLiteral) {
|
||||
using namespace fmt::literals;
|
||||
fmt::u8string_view s = "ab"_u;
|
||||
fmt::basic_string_view<char8_t> s = "ab"_u;
|
||||
EXPECT_EQ(s.size(), 2u);
|
||||
const char8_t* data = s.data();
|
||||
EXPECT_EQ(data[0], 'a');
|
||||
@ -2496,10 +2479,6 @@ TEST(FormatTest, U8StringViewLiteral) {
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(FormatTest, FormatU8String) {
|
||||
EXPECT_EQ(format(fmt::u8string_view("{}"), 42), fmt::u8string_view("42"));
|
||||
}
|
||||
|
||||
TEST(FormatTest, EmphasisNonHeaderOnly) {
|
||||
// Ensure this compiles even if FMT_HEADER_ONLY is not defined.
|
||||
EXPECT_EQ(fmt::format(fmt::emphasis::bold, "bold error"),
|
||||
|
Loading…
Reference in New Issue
Block a user