1 #ifndef SIPLASPLAS_CONSTEXPR_STRINGVIEW_HPP 2 #define SIPLASPLAS_CONSTEXPR_STRINGVIEW_HPP 4 #include "arrayview.hpp" 20 using ArrayView<char>::ArrayView;
22 constexpr
StringView(
const ArrayView<char>& arrayView) :
23 ArrayView<char>{arrayView}
26 constexpr StringView(ArrayView<char>&& arrayView) :
27 ArrayView<char>{std::move(arrayView)}
30 constexpr StringView(
char*
const str) :
31 ArrayView<char>{str, str + ::cpp::constexp::strlen(str)}
34 StringView(std::string& str) :
35 ArrayView<char>{&str[0], &str[str.size()]}
38 std::string str()
const 47 if((*
this)[size() - 1] ==
'\0')
57 constexpr
const char* c_str()
const 63 class ConstStringView :
public ConstArrayView<char>
66 using ConstArrayView<char>::ConstArrayView;
68 constexpr ConstStringView(
const ConstArrayView<char>& arrayView) :
69 ConstArrayView<char>{arrayView}
72 constexpr ConstStringView(ConstArrayView<char>&& arrayView) :
73 ConstArrayView<char>{std::move(arrayView)}
76 constexpr ConstStringView(
const char* str) :
77 ConstArrayView<char>{str, str + ::cpp::constexp::strlen(str)}
80 ConstStringView(
const std::string& str) :
81 ConstArrayView<char>{&str[0], &str[str.size()]}
84 std::string str()
const 93 if((*
this)[size() - 1] ==
'\0')
103 constexpr
const char* c_str()
const 109 using StringViews = ArrayView<const char*>;
110 using ConstStringViews = ConstArrayView<const char*>;
116 #endif // SIPLASPLAS_CONSTEXPR_STRINGVIEW_HPP Definition: canary_allocator.hpp:7
constexpr auto end(const Sequence &sequence)
Returns an iterator pointing to the end of a sequence.
Definition: algorithm.hpp:86
constexpr auto begin(const Sequence &sequence)
Returns an iterator pointing to the beginning of a sequence.
Definition: algorithm.hpp:62
Implements a constexpr reference to an slice of an string.
Definition: stringview.hpp:17