1 #ifndef _C4_STD_STRING_VIEW_HPP_
2 #define _C4_STD_STRING_VIEW_HPP_
6 #ifndef C4CORE_SINGLE_HEADER
7 #include "c4/language.hpp"
10 #if (C4_CPP >= 17 && defined(__cpp_lib_string_view)) || defined(__DOXYGEN__)
12 #ifndef C4CORE_SINGLE_HEADER
16 #include <string_view>
24 C4_ALWAYS_INLINE c4::csubstr
to_csubstr(std::string_view s) noexcept
26 return c4::csubstr(s.data(), s.size());
32 C4_ALWAYS_INLINE
bool operator== (c4::csubstr ss, std::string_view s) {
return ss.compare(s.data(), s.size()) == 0; }
33 C4_ALWAYS_INLINE
bool operator!= (c4::csubstr ss, std::string_view s) {
return ss.compare(s.data(), s.size()) != 0; }
34 C4_ALWAYS_INLINE
bool operator>= (c4::csubstr ss, std::string_view s) {
return ss.compare(s.data(), s.size()) >= 0; }
35 C4_ALWAYS_INLINE
bool operator> (c4::csubstr ss, std::string_view s) {
return ss.compare(s.data(), s.size()) > 0; }
36 C4_ALWAYS_INLINE
bool operator<= (c4::csubstr ss, std::string_view s) {
return ss.compare(s.data(), s.size()) <= 0; }
37 C4_ALWAYS_INLINE
bool operator< (c4::csubstr ss, std::string_view s) {
return ss.compare(s.data(), s.size()) < 0; }
39 C4_ALWAYS_INLINE
bool operator== (std::string_view s, c4::csubstr ss) {
return ss.compare(s.data(), s.size()) == 0; }
40 C4_ALWAYS_INLINE
bool operator!= (std::string_view s, c4::csubstr ss) {
return ss.compare(s.data(), s.size()) != 0; }
41 C4_ALWAYS_INLINE
bool operator<= (std::string_view s, c4::csubstr ss) {
return ss.compare(s.data(), s.size()) >= 0; }
42 C4_ALWAYS_INLINE
bool operator< (std::string_view s, c4::csubstr ss) {
return ss.compare(s.data(), s.size()) > 0; }
43 C4_ALWAYS_INLINE
bool operator>= (std::string_view s, c4::csubstr ss) {
return ss.compare(s.data(), s.size()) <= 0; }
44 C4_ALWAYS_INLINE
bool operator> (std::string_view s, c4::csubstr ss) {
return ss.compare(s.data(), s.size()) < 0; }
50 inline size_t to_chars(c4::substr buf, std::string_view s)
54 size_t len = buf.len < sz ? buf.len : sz;
60 C4_ASSERT(s.data() !=
nullptr);
61 C4_ASSERT(buf.str !=
nullptr);
62 memcpy(buf.str, s.data(), len);
csubstr to_csubstr(substr s) noexcept
neutral version for use in generic code
bool operator!=(const char(&s)[N], basic_substring< C > const that) noexcept
bool operator>(const char(&s)[N], basic_substring< C > const that) noexcept
bool operator>=(const char(&s)[N], basic_substring< C > const that) noexcept
bool operator<=(const char(&s)[N], basic_substring< C > const that) noexcept
bool operator==(const char(&s)[N], basic_substring< C > const that) noexcept
bool operator<(const char(&s)[N], basic_substring< C > const that) noexcept
size_t to_chars(substr buf, uint8_t v) noexcept