14 template<
typename Char,
typename TAllocator>
49 template<
class StringViewLike>
52 _init(view.data(), view.size());
71 _data._long._capacity = other._data._long._capacity;
72 _data._long._buffer = other._data._long._buffer;
73 other._data._long._buffer =
nullptr;
78 _data._short._buffer[i] = other._data._short._buffer[i];
85 TAllocator::free(
_data._long._buffer);
95 this->
_data._long._capacity = this->_length + 1;
96 this->
_data._long._buffer = (Char *) TAllocator::allocate(
sizeof(Char) * this->
_data._long._capacity);
98 this->
_data._long._buffer[this->_length] = 0;
111 this->_length = view.
size();
115 this->
_data._long._capacity = this->_length + 1;
116 this->
_data._long._buffer = (Char *) TAllocator::allocate(
sizeof(Char) * this->
_data._long._capacity);
117 memcpy(this->
_data._long._buffer, view.
data(),
sizeof(Char) * this->_length);
118 this->
_data._long._buffer[this->_length] = 0;
123 this->
_data._short._buffer[i] = view.
data()[i];
131 this->_length = other._length;
132 this->_is_long = other._is_long;
135 this->
_data._long._capacity = other._data._long._capacity;
136 this->
_data._long._buffer = other._data._long._buffer;
137 other._data._long._buffer =
nullptr;
142 this->
_data._short._buffer[i] = other._data._short._buffer[i];
172 return copy += other;
191 _data._short._buffer[new_length] = 0;
198 _data._long._buffer[new_length] = 0;
283 for (
size_t i = 0; i <
_length; i++)
291 _data._long._buffer = (Char *) TAllocator::allocate(
_data._long._capacity);
300 return _length < other_size ? -1 : 1;
310 const auto new_capacity =
sizeof(Char) * std::max(new_length,
_length) + 1;
311 const auto new_buffer = (Char *) TAllocator::allocate(new_capacity);
315 _data._long._buffer = new_buffer;
316 _data._long._capacity = new_capacity;
326 const auto capacity =
_data._long._capacity;
const CharT * data() 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
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)
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
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 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
mos::basic_string< char, mos::default_allocator > string
constexpr auto generic_strncmp(const CharT *a, const CharT *b, size_t n)
constexpr size_t short_string_capacity
constexpr auto generic_strlen(const CharT *c)
static void * memcpy(void *s1, const void *s2, size_t n)