From b55ea587053a01e242c8a83d84fa81e0acf7d973 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sat, 1 Feb 2020 08:38:00 -0800 Subject: [PATCH] string_view::char_type -> value_type (#1539) --- include/fmt/core.h | 5 +++-- test/core-test.cc | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) 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));