9 #ifndef LIBPMEMOBJ_CPP_STRING_VIEW
10 #define LIBPMEMOBJ_CPP_STRING_VIEW
15 #if __cpp_lib_string_view
16 #include <string_view>
25 #if __cpp_lib_string_view
27 template <
typename CharT,
typename Traits = std::
char_traits<CharT>>
28 using basic_string_view = std::basic_string_view<CharT, Traits>;
29 using string_view = std::string_view;
30 using wstring_view = std::basic_string_view<wchar_t>;
31 using u16string_view = std::basic_string_view<char16_t>;
32 using u32string_view = std::basic_string_view<char32_t>;
42 template <
typename CharT,
typename Traits = std::
char_traits<CharT>>
46 using traits_type = Traits;
47 using value_type = CharT;
48 using size_type = std::size_t;
49 using difference_type = std::ptrdiff_t;
50 using reference = value_type &;
51 using const_reference =
const value_type &;
52 using pointer = value_type *;
53 using const_pointer =
const value_type *;
64 const CharT *
data()
const noexcept;
65 size_type
size()
const noexcept;
67 const CharT &
operator[](size_type
p)
const noexcept;
72 const value_type *data_;
83 template <
typename CharT,
typename Traits>
85 : data_(
nullptr), size_(0)
96 template <
typename CharT,
typename Traits>
99 : data_(data), size_(size)
108 template <
typename CharT,
typename Traits>
110 const std::basic_string<CharT, Traits> &s)
111 : data_(s.c_str()), size_(s.size())
122 template <
typename CharT,
typename Traits>
124 : data_(data), size_(Traits::length(data))
135 template <
typename CharT,
typename Traits>
148 template <
typename CharT,
typename Traits>
149 inline typename basic_string_view<CharT, Traits>::size_type
160 template <
typename CharT,
typename Traits>
175 template <
typename CharT,
typename Traits>
180 int ret = Traits::compare(data(), other.data(),
181 (std::min)(size(), other.size()));
184 if (size() < other.size())
186 if (size() > other.size())
194 template <
class CharT,
class Traits>