mirror of
https://github.com/shadps4-emu/ext-fmt.git
synced 2024-11-23 09:49:42 +00:00
string_view::char_type -> value_type (#1539)
This commit is contained in:
parent
4098970db2
commit
b55ea58705
@ -313,7 +313,8 @@ template <typename Char> class basic_string_view {
|
|||||||
size_t size_;
|
size_t size_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using char_type = Char;
|
using char_type FMT_DEPRECATED_ALIAS = Char;
|
||||||
|
using value_type = Char;
|
||||||
using iterator = const Char*;
|
using iterator = const Char*;
|
||||||
|
|
||||||
FMT_CONSTEXPR basic_string_view() FMT_NOEXCEPT : data_(nullptr), size_(0) {}
|
FMT_CONSTEXPR basic_string_view() FMT_NOEXCEPT : data_(nullptr), size_(0) {}
|
||||||
@ -471,7 +472,7 @@ struct is_string : std::is_class<decltype(to_string_view(std::declval<S>()))> {
|
|||||||
template <typename S, typename = void> struct char_t_impl {};
|
template <typename S, typename = void> struct char_t_impl {};
|
||||||
template <typename S> struct char_t_impl<S, enable_if_t<is_string<S>::value>> {
|
template <typename S> struct char_t_impl<S, enable_if_t<is_string<S>::value>> {
|
||||||
using result = decltype(to_string_view(std::declval<S>()));
|
using result = decltype(to_string_view(std::declval<S>()));
|
||||||
using type = typename result::char_type;
|
using type = typename result::value_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct error_handler {
|
struct error_handler {
|
||||||
|
@ -402,8 +402,12 @@ TEST(ArgTest, VisitInvalidArg) {
|
|||||||
fmt::visit_format_arg(visitor, arg);
|
fmt::visit_format_arg(visitor, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(StringViewTest, ValueType) {
|
||||||
|
static_assert(std::is_same<string_view::value_type, char>::value, "");
|
||||||
|
}
|
||||||
|
|
||||||
TEST(StringViewTest, Length) {
|
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";
|
char str[100] = "some string";
|
||||||
EXPECT_EQ(std::strlen(str), string_view(str).size());
|
EXPECT_EQ(std::strlen(str), string_view(str).size());
|
||||||
EXPECT_LT(std::strlen(str), sizeof(str));
|
EXPECT_LT(std::strlen(str), sizeof(str));
|
||||||
|
Loading…
Reference in New Issue
Block a user