1 #ifndef _C4_STD_STRING_HPP_
2 #define _C4_STD_STRING_HPP_
6 #ifndef C4CORE_SINGLE_HEADER
15 template<
class T>
struct is_string;
16 template<>
struct is_string<std::string> :
public std::true_type {};
30 C4_ALWAYS_INLINE c4::substr
to_substr(std::string &s) noexcept
33 #error this function will have undefined behavior
36 return c4::substr(&s[0], s.size());
44 C4_ALWAYS_INLINE c4::csubstr
to_csubstr(std::string
const& s) noexcept
47 #error this function will have undefined behavior
50 return c4::csubstr(&s[0], s.size());
55 C4_ALWAYS_INLINE
bool operator== (c4::csubstr ss, std::string
const& s) {
return ss.compare(
to_csubstr(s)) == 0; }
56 C4_ALWAYS_INLINE
bool operator!= (c4::csubstr ss, std::string
const& s) {
return ss.compare(
to_csubstr(s)) != 0; }
57 C4_ALWAYS_INLINE
bool operator>= (c4::csubstr ss, std::string
const& s) {
return ss.compare(
to_csubstr(s)) >= 0; }
58 C4_ALWAYS_INLINE
bool operator> (c4::csubstr ss, std::string
const& s) {
return ss.compare(
to_csubstr(s)) > 0; }
59 C4_ALWAYS_INLINE
bool operator<= (c4::csubstr ss, std::string
const& s) {
return ss.compare(
to_csubstr(s)) <= 0; }
60 C4_ALWAYS_INLINE
bool operator< (c4::csubstr ss, std::string
const& s) {
return ss.compare(
to_csubstr(s)) < 0; }
62 C4_ALWAYS_INLINE
bool operator== (std::string
const& s, c4::csubstr ss) {
return ss.compare(
to_csubstr(s)) == 0; }
63 C4_ALWAYS_INLINE
bool operator!= (std::string
const& s, c4::csubstr ss) {
return ss.compare(
to_csubstr(s)) != 0; }
64 C4_ALWAYS_INLINE
bool operator>= (std::string
const& s, c4::csubstr ss) {
return ss.compare(
to_csubstr(s)) <= 0; }
65 C4_ALWAYS_INLINE
bool operator> (std::string
const& s, c4::csubstr ss) {
return ss.compare(
to_csubstr(s)) < 0; }
66 C4_ALWAYS_INLINE
bool operator<= (std::string
const& s, c4::csubstr ss) {
return ss.compare(
to_csubstr(s)) >= 0; }
67 C4_ALWAYS_INLINE
bool operator< (std::string
const& s, c4::csubstr ss) {
return ss.compare(
to_csubstr(s)) > 0; }
72 inline size_t to_chars(c4::substr buf, std::string
const& s)
75 size_t len = buf.len < sz ? buf.len : sz;
76 buf.copy_from(csubstr(s.data(), len));
84 substr(&(*s)[0], 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...