diff --git a/include/fmt/core.h b/include/fmt/core.h index 32bc88e3..6824c125 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -313,7 +313,8 @@ template class basic_string_view { size_t size_; public: - using char_type = Char; + using char_type FMT_DEPRECATED_ALIAS = Char; + using value_type = Char; using iterator = const Char*; FMT_CONSTEXPR basic_string_view() FMT_NOEXCEPT : data_(nullptr), size_(0) {} @@ -471,7 +472,7 @@ struct is_string : std::is_class()))> { template struct char_t_impl {}; template struct char_t_impl::value>> { using result = decltype(to_string_view(std::declval())); - using type = typename result::char_type; + using type = typename result::value_type; }; struct error_handler { diff --git a/test/core-test.cc b/test/core-test.cc index 08f27024..8f233ece 100644 --- a/test/core-test.cc +++ b/test/core-test.cc @@ -402,8 +402,12 @@ TEST(ArgTest, VisitInvalidArg) { fmt::visit_format_arg(visitor, arg); } +TEST(StringViewTest, ValueType) { + static_assert(std::is_same::value, ""); +} + TEST(StringViewTest, Length) { - // Test that StringRef::size() returns string length, not buffer size. + // Test that string_view::size() returns string length, not buffer size. char str[100] = "some string"; EXPECT_EQ(std::strlen(str), string_view(str).size()); EXPECT_LT(std::strlen(str), sizeof(str));