1 #ifndef _C4_STD_VECTOR_HPP_
2 #define _C4_STD_VECTOR_HPP_
9 #ifndef C4CORE_SINGLE_HEADER
13 #if defined(__GNUC__) && (__GNUC__ >= 6)
14 C4_SUPPRESS_WARNING_GCC_WITH_PUSH(
"-Wnull-dereference")
17 #if defined(__GNUC__) && (__GNUC__ >= 6)
18 C4_SUPPRESS_WARNING_GCC_POP
24 template<
class T>
struct is_string;
25 template<
class Alloc>
struct is_string<std::vector<char,Alloc>> :
public std::true_type {};
38 char *data = vec.empty() ? nullptr : vec.data();
39 return c4::substr(data, vec.size());
44 c4::csubstr
to_csubstr(std::vector<char, Alloc>
const& vec)
46 const char *data = vec.empty() ? nullptr : vec.data();
47 return c4::csubstr(data, vec.size());
54 template<
class Alloc> C4_ALWAYS_INLINE
bool operator!= (c4::csubstr ss, std::vector<char, Alloc>
const& s) {
return ss !=
to_csubstr(s); }
55 template<
class Alloc> C4_ALWAYS_INLINE
bool operator== (c4::csubstr ss, std::vector<char, Alloc>
const& s) {
return ss ==
to_csubstr(s); }
56 template<
class Alloc> C4_ALWAYS_INLINE
bool operator>= (c4::csubstr ss, std::vector<char, Alloc>
const& s) {
return ss >=
to_csubstr(s); }
57 template<
class Alloc> C4_ALWAYS_INLINE
bool operator> (c4::csubstr ss, std::vector<char, Alloc>
const& s) {
return ss >
to_csubstr(s); }
58 template<
class Alloc> C4_ALWAYS_INLINE
bool operator<= (c4::csubstr ss, std::vector<char, Alloc>
const& s) {
return ss <=
to_csubstr(s); }
59 template<
class Alloc> C4_ALWAYS_INLINE
bool operator< (c4::csubstr ss, std::vector<char, Alloc>
const& s) {
return ss <
to_csubstr(s); }
61 template<
class Alloc> C4_ALWAYS_INLINE
bool operator!= (std::vector<char, Alloc>
const& s, c4::csubstr ss) {
return ss !=
to_csubstr(s); }
62 template<
class Alloc> C4_ALWAYS_INLINE
bool operator== (std::vector<char, Alloc>
const& s, c4::csubstr ss) {
return ss ==
to_csubstr(s); }
63 template<
class Alloc> C4_ALWAYS_INLINE
bool operator>= (std::vector<char, Alloc>
const& s, c4::csubstr ss) {
return ss <=
to_csubstr(s); }
64 template<
class Alloc> C4_ALWAYS_INLINE
bool operator> (std::vector<char, Alloc>
const& s, c4::csubstr ss) {
return ss <
to_csubstr(s); }
65 template<
class Alloc> C4_ALWAYS_INLINE
bool operator<= (std::vector<char, Alloc>
const& s, c4::csubstr ss) {
return ss >=
to_csubstr(s); }
66 template<
class Alloc> C4_ALWAYS_INLINE
bool operator< (std::vector<char, Alloc>
const& s, c4::csubstr ss) {
return ss >
to_csubstr(s); }
73 inline size_t to_chars(c4::substr buf, std::vector<char, Alloc>
const& s)
76 size_t len = buf.len < sz ? buf.len : sz;
77 buf.copy_from(csubstr(s.data(), len));
83 inline bool from_chars(c4::csubstr buf, std::vector<char, Alloc> * s)
86 substr(s->data(), buf.len).copy_from(buf);
bool from_chars(csubstr buf, uint8_t *v) noexcept
csubstr to_csubstr(substr s) noexcept
neutral version for use in generic code
substr to_substr(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
(Undefined by default) Use shorter error message from checks/asserts: do not show the check condition...
a traits class to mark a type as a string type (meaning c4::to_csubstr() can be used directly).
a traits class to mark a type as a writeable string type (meaning c4::to_substr() can be used directl...