MCPcopy Create free account
hub / github.com/arun11299/cpp-jwt / basic_string_view

Class basic_string_view

include/jwt/string_view.hpp:52–368  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50 typename Traits = std::char_traits<CharT>
51>
52class basic_string_view
53{
54public: // Member Types
55 using traits_type = std::char_traits<CharT>;
56 using value_type = CharT;
57 using pointer = const CharT*;
58 using const_pointer = const CharT*;
59 using reference = const CharT&;
60 using const_reference = const CharT&;
61 using iterator = const CharT*;
62 using const_iterator = const CharT*;
63 using reverse_iterator = std::reverse_iterator<iterator>;
64 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
65 using size_type = size_t;
66 using difference_type = std::ptrdiff_t;
67
68 static constexpr size_type npos = size_type(-1);
69
70public: // 'tors
71 /// The default constructor;
72 basic_string_view() = default;
73
74 /// Construct from string literal
75 basic_string_view(const CharT* str) noexcept
76 : data_(str)
77 , len_(str ? traits_type::length(str) : 0)
78 {
79 }
80
81 /// Construct from CharT pointer and provided length
82 basic_string_view(const CharT* p, size_type len) noexcept
83 : data_(p)
84 , len_(len)
85 {
86 }
87
88 /// Construct from std::string
89 template <typename Allocator>
90 basic_string_view(
91 const std::basic_string<CharT, Traits, Allocator>& str) noexcept
92 : data_(str.data())
93 , len_(str.length())
94 {
95 }
96
97 /// Copy constructor
98 basic_string_view(const basic_string_view&) = default;
99
100 /// Assignment operator
101 basic_string_view& operator=(const basic_string_view&) = default;
102
103 /// Destructor
104 ~basic_string_view()
105 {
106 data_ = nullptr;
107 len_ = 0;
108 }
109

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected