14 template<
typename Char,
typename TAllocator = mos::default_allocator<Char>>
52 template<
class StringViewLike>
55 _init(view.data(), view.size());
74 _data._long._capacity = other._data._long._capacity;
75 _data._long._buffer = other._data._long._buffer;
76 other._data._long._buffer =
nullptr;
81 _data._short._buffer[i] = other._data._short._buffer[i];
88 TAllocator::free(
_data._long._buffer);
100 this->
_data._long._capacity = this->_length + 1;
101 this->
_data._long._buffer = (Char *) TAllocator::allocate(
sizeof(Char) * this->
_data._long._capacity);
103 this->
_data._long._buffer[this->_length] = 0;
116 this->_length = view.
size();
120 this->
_data._long._capacity = this->_length + 1;
121 this->
_data._long._buffer = (Char *) TAllocator::allocate(
sizeof(Char) * this->
_data._long._capacity);
122 memcpy(this->
_data._long._buffer, view.
data(),
sizeof(Char) * this->_length);
123 this->
_data._long._buffer[this->_length] = 0;
128 this->
_data._short._buffer[i] = view.
data()[i];
136 this->_length = other._length;
137 this->_is_long = other._is_long;
140 this->
_data._long._capacity = other._data._long._capacity;
141 this->
_data._long._buffer = other._data._long._buffer;
142 other._data._long._buffer =
nullptr;
147 this->
_data._short._buffer[i] = other._data._short._buffer[i];
178 return _data._short._buffer[0] == c;
206 TAllocator::free(
_data._long._buffer);
207 _data._long._buffer =
nullptr;
216 return copy += other;
235 _data._short._buffer[new_length] = 0;
242 _data._long._buffer[new_length] = 0;
296 return empty() ? other : *
this;
342 for (
size_t i = 0; i <
_length; i++)
350 _data._long._buffer = (Char *) TAllocator::allocate(
_data._long._capacity);
359 return _length < other_size ? -1 : 1;
369 const auto new_capacity =
sizeof(Char) * std::max(new_length,
_length) + 1;
370 const auto new_buffer = (Char *) TAllocator::allocate(new_capacity);
374 _data._long._buffer = new_buffer;
375 _data._long._capacity = new_capacity;
385 const auto capacity =
_data._long._capacity;
const CharT * data() const
bool ends_with(const basic_string_view< Char > &suffix) const
basic_string operator+(Char c) const
basic_string & operator=(basic_string &&other)
basic_string & operator=(const Char *buffer)
bool operator==(const basic_string &other) const
const Char * begin() const
bool begins_with(Char c) const
basic_string & operator=(const basic_string &other)
const Char * c_str() const
basic_string(const Char *buffer)
basic_string operator+(const basic_string &other) const
int _do_compare(const Char *other, const size_t other_size) const
Char & operator[](size_t index)
basic_string & operator+=(const basic_string_view< Char > &other)
basic_string_view< Char > value_or(basic_string_view< Char > other) const
union mos::basic_string::@316261373317277370236264047140336051253031235271 _data
void _init(const Char *buffer, size_t size)
struct mos::basic_string::@316261373317277370236264047140336051253031235271::_long_buffer _long
struct mos::basic_string::@316261373317277370236264047140336051253031235271::_short_buffer _short
static constexpr auto npos
basic_string & operator+=(Char c)
basic_string(basic_string &&other)
basic_string(const basic_string &other)
void _convert_to_long(size_t new_length=0)
const Char & operator[](size_t index) const
basic_string(std::nullptr_t)=delete
basic_string & operator=(const mos::basic_string_view< Char > &view)
bool begins_with(const basic_string_view< Char > &prefix) const
bool operator==(const char *rhs) const
basic_string(const Char *buffer, size_t size)
basic_string(const StringViewLike &view)
bool operator==(std::nullptr_t) const =delete
friend basic_string operator+(const basic_string_view< Char > &lhs, const basic_string &rhs)
void resize(size_t new_length)
basic_string(size_t size, Char c=0)
const Char * data() const
bool ends_with(Char c) const
ssize_t copy(char *buffer, size_t size, size_t pos=0) const
mos::string to_string(const void *value)
constexpr auto generic_strncmp(const CharT *a, const CharT *b, size_t n)
mos::basic_string< char > string
void __raise_null_pointer_exception()
constexpr size_t short_string_capacity
constexpr auto generic_strlen(const CharT *c)
static void * memcpy(void *s1, const void *s2, size_t n)