9 #ifndef LIBPMEMOBJ_CPP_STRING_VIEW
10 #define LIBPMEMOBJ_CPP_STRING_VIEW
16 #if __cpp_lib_string_view
17 #include <string_view>
26 #if __cpp_lib_string_view
28 template <
typename CharT,
typename Traits = std::
char_traits<CharT>>
29 using basic_string_view = std::basic_string_view<CharT, Traits>;
30 using string_view = std::string_view;
31 using wstring_view = std::basic_string_view<wchar_t>;
32 using u16string_view = std::basic_string_view<char16_t>;
33 using u32string_view = std::basic_string_view<char32_t>;
43 template <
typename CharT,
typename Traits = std::
char_traits<CharT>>
47 using traits_type = Traits;
48 using value_type = CharT;
49 using size_type = std::size_t;
50 using difference_type = std::ptrdiff_t;
51 using reference = value_type &;
52 using const_reference =
const value_type &;
53 using pointer = value_type *;
54 using const_pointer =
const value_type *;
65 const CharT *
data()
const noexcept;
66 size_type
size()
const noexcept;
68 const CharT &
operator[](size_type
p)
const noexcept;
73 const value_type *data_;
84 template <
typename CharT,
typename Traits>
86 : data_(
nullptr), size_(0)
97 template <
typename CharT,
typename Traits>
100 : data_(data), size_(size)
109 template <
typename CharT,
typename Traits>
111 const std::basic_string<CharT, Traits> &s)
112 : data_(s.c_str()), size_(s.size())
123 template <
typename CharT,
typename Traits>
125 : data_(data), size_(Traits::length(data))
136 template <
typename CharT,
typename Traits>
149 template <
typename CharT,
typename Traits>
150 inline typename basic_string_view<CharT, Traits>::size_type
161 template <
typename CharT,
typename Traits>
177 template <
typename CharT,
typename Traits>
182 int ret = Traits::compare(data(), other.data(),
183 (std::min)(size(), other.size()));
186 if (size() < other.size())
188 if (size() > other.size())
196 template <
class CharT,
class Traits>