157 :
public inline_string_detail::inline_string_base
158 ,
public detail::mixin_at<inline_string<MaxSize>,
typename inline_string_detail::inline_string_base::size_type>
159 , inline_string_std_string_mixin<inline_string<MaxSize>>
160 , generic_ordering_from_three_way_compare<inline_string<MaxSize>> {
162 using ordering_base = generic_ordering_from_three_way_compare<inline_string<MaxSize>>;
166 using integral_comparison_result =
int;
173 cmp_less(MaxSize, std::numeric_limits<difference_type>::max()),
174 "Must have ability to get difference between iterators"
179 using typename inline_string_base::size_type;
180 using typename inline_string_base::value_type;
182 using typename inline_string_base::const_reference;
183 using typename inline_string_base::reference;
185 using typename inline_string_base::const_pointer;
186 using typename inline_string_base::pointer;
188 using typename inline_string_base::const_iterator;
189 using typename inline_string_base::const_reverse_iterator;
190 using typename inline_string_base::iterator;
191 using typename inline_string_base::reverse_iterator;
193 using inline_string_std_string_mixin<inline_string>::three_way_compare;
194 using inline_string_std_string_mixin<inline_string>::fast_inequality_check;
198 static constexpr size_type npos{string_view::npos};
202 ~inline_string() =
default;
205 constexpr inline_string()
noexcept =
default;
209 constexpr inline_string(inline_string
const&) =
default;
214 constexpr inline_string(inline_string&&) =
default;
227 constexpr explicit inline_string(detail::raw_c_string
const str)
noexcept
242 template <std::size_t N>
244 constexpr inline_string(detail::character
const (&str)[N])
noexcept
246 static_assert(N - 1UL <= MaxSize,
"String literal must fit into MaxLength");
249 string_view as_view{&str[0], N};
250 auto const first_nul_idx = as_view.find(
'\0');
251 ARENE_PRECONDITION(first_nul_idx < as_view.size());
252 as_view = as_view.substr(0UL, first_nul_idx);
255 copy_from_unchecked(as_view);
269 constexpr explicit inline_string(string_view
const str)
noexcept
283 static constexpr auto try_construct(string_view
const str)
noexcept -> optional<inline_string> {
284 if (str.length() > MaxSize) {
287 return {inline_string{str}};
299 template <size_type OtherMaxLength, constraints<std::enable_if_t<(OtherMaxLength <= MaxSize)>> =
nullptr>
301 constexpr inline_string(inline_string<OtherMaxLength>
const& other)
noexcept
316 template <size_type OtherMaxLength, constraints<std::enable_if_t<(OtherMaxLength > MaxSize)>> =
nullptr>
317 constexpr explicit inline_string(inline_string<OtherMaxLength>
const& other)
noexcept
333 constexpr inline_string(size_type len, detail::character chr)
noexcept
346 template <size_type OtherMaxSize, constraints<std::enable_if_t<(OtherMaxSize <= MaxSize)>> =
nullptr>
347 static constexpr auto try_construct(inline_string<OtherMaxSize>
const& str)
noexcept -> optional<inline_string> {
348 return {inline_string{str}};
355 template <size_type OtherMaxSize, constraints<std::enable_if_t<(OtherMaxSize > MaxSize)>> =
nullptr>
356 static constexpr auto try_construct(inline_string<OtherMaxSize>
const& str)
noexcept -> optional<inline_string> {
357 if (str.length() > MaxSize) {
360 return {inline_string{str}};
371 template <
typename InputIterator, constraints<std::enable_if_t<is_input_iterator_v<InputIterator>>> =
nullptr>
372 constexpr explicit inline_string(
373 InputIterator
const first,
374 InputIterator
const last
375 )
noexcept(denotes_nothrow_iterable_range_v<InputIterator>)
377 copy_from(
typename std::iterator_traits<InputIterator>::iterator_category{}, first, last);
388 template <
typename InputIterator, constraints<std::enable_if_t<is_input_iterator_v<InputIterator>>> =
nullptr>
389 static constexpr auto
390 try_construct(InputIterator first, InputIterator last)
noexcept(denotes_nothrow_iterable_range_v<InputIterator>)
391 -> optional<inline_string> {
392 return inline_string::do_try_construct(
393 typename std::iterator_traits<InputIterator>::iterator_category{},
402 constexpr auto operator=(inline_string
const&) -> inline_string& =
default;
408 constexpr auto operator=(inline_string&&) -> inline_string& =
default;
418 constexpr auto operator=(string_view str)
noexcept -> inline_string& {
431 constexpr auto operator=(detail::raw_c_string str)
noexcept -> inline_string& {
443 constexpr auto operator=(std::initializer_list<detail::character> str)
noexcept -> inline_string& {
444 copy_from(string_view(str.begin(), str.size()));
454 constexpr auto operator=(detail::character chr)
noexcept -> inline_string& {
455 copy_from_unchecked(string_view(&chr, 1U));
467 template <std::size_t OtherMaxLength>
468 constexpr auto operator=(inline_string<OtherMaxLength>
const& other)
noexcept -> inline_string& {
480 constexpr auto assign(string_view str)
noexcept -> inline_string& {
return *
this = str; }
490 constexpr auto assign(string_view str, size_type pos)
noexcept -> inline_string& {
return assign(str.substr(pos)); }
501 constexpr auto assign(string_view str, size_type pos, size_type count)
noexcept -> inline_string& {
502 return assign(str.substr(pos, count));
512 constexpr auto assign(std::initializer_list<detail::character> str)
noexcept -> inline_string& {
return *
this = str; }
525 constexpr auto assign(detail::raw_c_string str, size_type count)
noexcept -> inline_string& {
526 return assign(string_view{str, count});
535 constexpr auto assign(detail::character chr)
noexcept -> inline_string& {
return *
this = chr; }
543 constexpr auto assign(size_type count, detail::character chr)
noexcept -> inline_string& {
544 ARENE_PRECONDITION(count <= MaxSize);
559 constexpr auto insert(size_type pos, string_view str)
noexcept -> inline_string& {
560 std::ignore = ::arene::base::copy(str.begin(), str.end(), prepare_insert(pos, str.size()));
574 constexpr auto insert(size_type pos1, string_view str, size_type pos2)
noexcept -> inline_string& {
575 return insert(pos1, str.substr(pos2));
589 constexpr auto insert(size_type pos1, string_view str, size_type pos2, size_type length2)
noexcept -> inline_string& {
590 return insert(pos1, str.substr(pos2, length2));
604 constexpr auto insert(size_type pos, detail::raw_c_string str, size_type count)
noexcept -> inline_string& {
605 return insert(pos, string_view{str, count});
619 constexpr auto insert(size_type pos, size_type count, detail::character chr)
noexcept -> inline_string& {
620 auto const insert_begin = prepare_insert(pos, count);
621 ::arene::base::fill(insert_begin, insert_begin +
static_cast<difference_type>(count), chr);
634 constexpr auto insert(const_iterator pos, detail::character chr)
noexcept -> iterator {
return insert(pos, 1U, chr); }
647 constexpr auto insert(const_iterator pos, size_type count, detail::character chr)
noexcept -> iterator {
648 auto const offset = pos - cbegin();
649 std::ignore = insert(
static_cast<size_type>(offset), count, chr);
650 return begin() + offset;
662 constexpr auto insert(const_iterator pos, std::initializer_list<detail::character> chars)
noexcept -> iterator {
663 auto const offset = pos - cbegin();
664 std::ignore = insert(
static_cast<size_type>(offset), string_view{chars.begin(), chars.size()});
665 return begin() + offset;
679 template <
typename InputIterator, constraints<std::enable_if_t<base::is_input_iterator_v<InputIterator>>> =
nullptr>
680 constexpr auto insert(
684 )
noexcept(denotes_nothrow_iterable_range_v<InputIterator>) -> iterator {
685 return do_insert(
typename std::iterator_traits<InputIterator>::iterator_category{}, pos, first, last);
690 constexpr auto erase()
noexcept -> inline_string& {
699 constexpr auto erase(size_type pos) -> inline_string& {
701 return erase(pos,
this->size() - pos);
712 constexpr auto erase(size_type pos, size_type count)
noexcept -> inline_string& {
713 if (pos <
this->size()) {
714 count = std::min(count,
this->size() - pos);
716 size_type
const erase_end{pos + count};
717 std::ignore = ::arene::base::copy(
718 begin() +
static_cast<difference_type>(erase_end),
720 begin() +
static_cast<difference_type>(pos)
722 set_null_terminator_to(
this->size() - count);
733 constexpr auto erase(const_iterator pos)
noexcept -> iterator {
734 auto const offset = pos - cbegin();
735 ARENE_PRECONDITION((offset >= 0) && (
static_cast<size_type>(offset) <=
this->size()));
736 std::ignore = erase(
static_cast<size_type>(offset), 1U);
737 return begin() + offset;
747 constexpr auto erase(const_iterator first, const_iterator last)
noexcept -> iterator {
748 ARENE_PRECONDITION(last >= first);
749 auto const offset = first - cbegin();
750 ARENE_PRECONDITION(offset >= 0);
751 std::ignore = erase(
static_cast<size_type>(offset),
static_cast<size_type>(last - first));
752 return begin() + offset;
767 constexpr auto replace(size_type pos, size_type count, string_view str)
noexcept -> inline_string& {
768 prepare_replace(pos, count, str.length());
769 std::ignore = ::arene::base::copy(str.begin(), str.end(), begin() +
static_cast<difference_type>(pos));
788 constexpr auto replace(size_type pos, size_type count, string_view str, size_type pos2)
noexcept -> inline_string& {
789 return replace(pos, count, str.substr(pos2));
808 constexpr auto replace(size_type pos, size_type count, string_view str, size_type pos2, size_type count2)
noexcept
810 return replace(pos, count, str.substr(pos2, count2));
828 constexpr auto replace(size_type pos, size_type count, detail::raw_c_string str, size_type count2)
noexcept
830 return replace(pos, count, string_view{str, count2});
848 constexpr auto replace(size_type pos, size_type count, size_type count2, detail::character chr)
noexcept
850 prepare_replace(pos, count, count2);
851 auto const fill_begin = begin() +
static_cast<difference_type>(pos);
852 ::arene::base::fill(fill_begin, fill_begin +
static_cast<difference_type>(count2), chr);
870 constexpr auto replace(const_iterator first, const_iterator last, string_view str)
noexcept -> inline_string& {
871 ARENE_PRECONDITION(last >= first);
872 auto const offset = first - cbegin();
873 ARENE_PRECONDITION(offset >= 0);
874 return replace(
static_cast<size_type>(offset),
static_cast<size_type>(last - first), str);
893 constexpr auto replace(const_iterator first, const_iterator last, string_view str, size_type pos)
noexcept
895 return replace(first, last, str.substr(pos));
916 replace(const_iterator first, const_iterator last, string_view str, size_type pos, size_type count)
noexcept
918 return replace(first, last, str.substr(pos, count));
938 constexpr auto replace(const_iterator first, const_iterator last, detail::raw_c_string str, size_type count)
noexcept
940 return replace(first, last, string_view{str, count});
958 constexpr auto replace(const_iterator first, const_iterator last, size_type count, detail::character chr)
noexcept
960 ARENE_PRECONDITION(last >= first);
961 auto const offset = first - cbegin();
962 ARENE_PRECONDITION(offset >= 0);
963 return replace(
static_cast<size_type>(offset),
static_cast<size_type>(last - first), count, chr);
981 replace(const_iterator first, const_iterator last, std::initializer_list<detail::character> chars)
noexcept
983 return replace(first, last, string_view{chars.begin(), chars.size()});
1003 typename InputIterator,
1005 std::enable_if_t<base::is_input_iterator_v<InputIterator>>,
1006 std::enable_if_t<!base::is_random_access_iterator_v<InputIterator>>> =
nullptr>
1007 constexpr auto replace(
1008 const_iterator first,
1009 const_iterator last,
1010 InputIterator first2,
1012 )
noexcept(denotes_nothrow_iterable_range_v<InputIterator>) -> inline_string& {
1013 return replace(first, last, inline_string{first2, last2});
1032 typename RandomAccessIterator,
1033 constraints<std::enable_if_t<base::is_random_access_iterator_v<RandomAccessIterator>>> =
nullptr>
1034 constexpr auto replace(
1035 const_iterator first,
1036 const_iterator last,
1037 RandomAccessIterator first2,
1038 RandomAccessIterator last2
1039 )
noexcept(denotes_nothrow_iterable_range_v<RandomAccessIterator>) -> inline_string& {
1040 auto const length_of_replacement = last2 - first2;
1041 ARENE_PRECONDITION(length_of_replacement >= 0);
1042 ARENE_PRECONDITION(last >= first);
1043 auto const offset = first - cbegin();
1044 ARENE_PRECONDITION(offset >= 0);
1045 inline_string::size_type pos{
static_cast<inline_string::size_type>(offset)};
1048 static_cast<inline_string::size_type>(last - first),
1049 static_cast<inline_string::size_type>(length_of_replacement)
1051 std::ignore = ::arene::base::copy(first2, last2, begin() + offset);
1058 constexpr void pop_back()
noexcept {
1059 ARENE_PRECONDITION(!empty());
1060 std::ignore = erase(
this->size() - 1U);
1069 constexpr auto copy(detail::character* str, size_type count)
const -> size_type {
1070 return string_view{*
this}.copy(str, count);
1081 constexpr auto copy(detail::character* str, size_type count, size_type pos)
const -> size_type {
1082 return string_view{*
this}.copy(str, count, pos);
1087 ARENE_NODISCARD
constexpr auto substr()
const noexcept -> inline_string {
return *
this; }
1094 ARENE_NODISCARD
constexpr auto substr(size_type pos)
const noexcept -> inline_string {
1095 return inline_string{string_view{*
this}.substr(pos)};
1104 ARENE_NODISCARD
constexpr auto substr(size_type pos, size_type n)
const noexcept -> inline_string {
1105 return inline_string{string_view{*
this}.substr(pos, n)};
1112 ARENE_NODISCARD
constexpr auto empty()
const noexcept ->
bool {
return this->size() == 0U; }
1117 ARENE_NODISCARD
constexpr auto c_str()
const noexcept -> detail::raw_c_string {
return data(); }
1122 ARENE_NODISCARD
constexpr auto data()
const noexcept -> detail::raw_c_string {
return buffer_.data(); }
1127 ARENE_NODISCARD
constexpr auto data()
noexcept -> detail::character* {
return buffer_.data(); }
1131 static constexpr auto capacity() -> std::size_t {
return MaxSize; }
1135 static constexpr auto max_size() -> std::size_t {
return capacity(); }
1140 constexpr void clear()
noexcept { set_null_terminator_to(0U); }
1150 constexpr void resize(size_type new_size, detail::character new_char =
'\0')
noexcept {
1151 ARENE_PRECONDITION(new_size <= max_size());
1152 inline_string::iterator original_end{end()};
1153 set_null_terminator_to(new_size);
1154 ::arene::base::fill(std::min(original_end, end()), end(), new_char);
1163 ARENE_NODISCARD
constexpr auto operator[](size_type index)
const noexcept -> detail::character
const& {
1164 ARENE_PRECONDITION(index <=
this->size());
1165 return buffer_[index];
1174 ARENE_NODISCARD
constexpr auto operator[](size_type index)
noexcept -> detail::character& {
1175 ARENE_PRECONDITION(index <=
this->size());
1176 return buffer_[index];
1184 ARENE_NODISCARD
constexpr auto front()
const noexcept -> detail::character
const& {
1185 ARENE_PRECONDITION(!empty());
1186 return buffer_.front();
1193 ARENE_NODISCARD
constexpr auto front()
noexcept -> detail::character& {
1194 ARENE_PRECONDITION(!empty());
1195 return buffer_.front();
1202 ARENE_NODISCARD
constexpr auto back()
const noexcept -> detail::character
const& {
1203 ARENE_PRECONDITION(!empty());
1204 return buffer_[
this->size() - 1U];
1211 ARENE_NODISCARD
constexpr auto back()
noexcept -> detail::character& {
1212 ARENE_PRECONDITION(!empty());
1213 return buffer_[
this->size() - 1U];
1220 ARENE_NODISCARD
constexpr auto begin()
noexcept -> iterator {
1221 return iterator(iterator_passkey{}, buffer_.begin().base());
1228 ARENE_NODISCARD
constexpr auto begin()
const noexcept -> const_iterator {
1229 return const_iterator(iterator_passkey{}, buffer_.begin().base());
1235 ARENE_NODISCARD
constexpr auto cbegin()
const noexcept -> const_iterator {
return begin(); }
1240 ARENE_NODISCARD
constexpr auto end()
noexcept -> iterator {
1241 return begin() +
static_cast<difference_type>(
this->size());
1247 ARENE_NODISCARD
constexpr auto end()
const noexcept -> const_iterator {
1248 return begin() +
static_cast<difference_type>(
this->size());
1253 ARENE_NODISCARD
constexpr auto cend()
const noexcept -> const_iterator {
return end(); }
1258 ARENE_NODISCARD
constexpr auto rbegin()
noexcept -> reverse_iterator {
return reverse_iterator(end()); }
1263 ARENE_NODISCARD
auto rbegin()
const noexcept -> const_reverse_iterator {
return const_reverse_iterator(end()); }
1268 ARENE_NODISCARD
auto crbegin()
const noexcept -> const_reverse_iterator {
return rbegin(); }
1273 ARENE_NODISCARD
constexpr auto rend()
noexcept -> reverse_iterator {
return reverse_iterator(begin()); }
1278 ARENE_NODISCARD
auto rend()
const noexcept -> const_reverse_iterator {
return const_reverse_iterator(begin()); }
1283 ARENE_NODISCARD
auto crend()
const noexcept -> const_reverse_iterator {
return rend(); }
1294 template <std::size_t OtherMaxLength>
1295 ARENE_NODISCARD
static constexpr auto
1296 three_way_compare(inline_string
const& lhs, inline_string<OtherMaxLength>
const& rhs)
noexcept -> strong_ordering {
1297 return string_view::three_way_compare(string_view{lhs}, string_view{rhs});
1307 ARENE_NODISCARD
static constexpr auto three_way_compare(inline_string
const& lhs, string_view rhs)
noexcept
1308 -> strong_ordering {
1309 return string_view::three_way_compare(string_view{lhs}, rhs);
1319 ARENE_NODISCARD
static constexpr auto three_way_compare(inline_string
const& lhs, detail::raw_c_string rhs)
noexcept
1320 -> strong_ordering {
1321 return string_view::three_way_compare(string_view{lhs}, rhs);
1331 ARENE_NODISCARD
static constexpr auto
1332 three_way_compare(inline_string
const& lhs, null_terminated_string_view rhs)
noexcept -> strong_ordering {
1333 return inline_string::three_way_compare(lhs, rhs.c_str());
1343 template <std::size_t OtherMaxLength>
1344 ARENE_NODISCARD
static constexpr auto
1345 fast_inequality_check(inline_string
const& lhs, inline_string<OtherMaxLength>
const& rhs)
noexcept
1346 -> inequality_heuristic {
1347 return inline_string::fast_inequality_check(lhs, string_view{rhs});
1356 ARENE_NODISCARD
static constexpr auto fast_inequality_check(inline_string
const& lhs, string_view rhs)
noexcept
1357 -> inequality_heuristic {
1358 return inline_string_base::common_fast_inequality_check(lhs, rhs);
1369 constexpr auto append(string_view rhs)
noexcept -> inline_string& {
1370 ARENE_PRECONDITION(
this->size() + rhs.size() <= max_size());
1371 std::ignore = ::arene::base::copy(rhs.begin(), rhs.end(), begin() +
static_cast<difference_type>(
this->size()));
1372 set_null_terminator_to(
this->size() + rhs.size());
1383 constexpr auto append(detail::character rhs)
noexcept -> inline_string& {
return append(string_view{&rhs, 1U}); }
1392 constexpr auto append(std::initializer_list<detail::character> rhs)
noexcept -> inline_string& {
1393 return append(string_view{rhs.begin(), rhs.size()});
1404 constexpr auto append(string_view rhs, size_type pos)
noexcept -> inline_string& {
return append(rhs.substr(pos)); }
1415 constexpr auto append(string_view rhs, size_type pos, size_type count)
noexcept -> inline_string& {
1416 return append(rhs.substr(pos, count));
1427 constexpr auto append(detail::raw_c_string rhs, size_type count)
noexcept -> inline_string& {
1428 return append(string_view{rhs, count});
1441 constexpr auto append(size_type count, detail::character chr)
noexcept -> inline_string& {
1442 resize(
this->size() + count, chr);
1452 constexpr void push_back(detail::character rhs)
noexcept { std::ignore = append(rhs); }
1461 constexpr auto operator+=(string_view rhs)
noexcept -> inline_string& {
return append(rhs); }
1470 constexpr auto operator+=(detail::character rhs)
noexcept -> inline_string& {
return append(rhs); }
1479 constexpr auto operator+=(std::initializer_list<detail::character> rhs)
noexcept -> inline_string& {
1490 ARENE_NODISCARD
constexpr operator string_view()
const noexcept {
1493 return {c_str(), std::min(
this->size(), max_size())};
1504 ARENE_NODISCARD
constexpr operator null_terminated_string_view()
const noexcept {
1505 return null_terminated_string_view{c_str()};
1514 ARENE_NODISCARD
constexpr auto find(string_view str, size_type pos = 0U)
const noexcept -> size_type {
1515 return string_view{*
this}.find(str, pos);
1522 ARENE_NODISCARD
constexpr auto find(detail::character chr)
const noexcept -> size_type {
1523 return find(string_view{&chr, 1U});
1531 ARENE_NODISCARD
constexpr auto find(detail::character chr, size_type pos)
const noexcept -> size_type {
1532 return find(string_view{&chr, 1U}, pos);
1539 ARENE_NODISCARD
constexpr auto find(detail::raw_c_string str)
const noexcept -> size_type {
1540 return find(string_view{str});
1548 ARENE_NODISCARD
constexpr auto find(detail::raw_c_string str, size_type pos)
const noexcept -> size_type {
1549 return find(string_view{str}, pos);
1559 ARENE_NODISCARD
constexpr auto find(detail::raw_c_string str, size_type pos, size_type count)
const noexcept
1561 return find(string_view{str, count}, pos);
1568 ARENE_NODISCARD
constexpr auto rfind(string_view str)
const noexcept -> size_type {
return rfind(str,
this->size()); }
1575 ARENE_NODISCARD
constexpr auto rfind(string_view str, size_type pos)
const noexcept -> size_type {
1576 return string_view{*
this}.rfind(str, pos);
1583 ARENE_NODISCARD
constexpr auto rfind(detail::character chr)
const noexcept -> size_type {
1584 return rfind(string_view{&chr, 1U});
1592 ARENE_NODISCARD
constexpr auto rfind(detail::character chr, size_type pos)
const noexcept -> size_type {
1593 return rfind(string_view{&chr, 1U}, pos);
1600 ARENE_NODISCARD
constexpr auto rfind(detail::raw_c_string str)
const noexcept -> size_type {
1601 return rfind(string_view{str});
1609 ARENE_NODISCARD
constexpr auto rfind(detail::raw_c_string str, size_type pos)
const noexcept -> size_type {
1610 return rfind(string_view{str}, pos);
1620 ARENE_NODISCARD
constexpr auto rfind(detail::raw_c_string str, size_type pos, size_type count)
const noexcept
1622 return rfind(string_view{str, count}, pos);
1629 ARENE_NODISCARD
constexpr auto find_first_of(string_view str)
const noexcept -> size_type {
1630 return find_first_of(str, 0U);
1639 ARENE_NODISCARD
constexpr auto find_first_of(string_view str, size_type pos)
const noexcept -> size_type {
1640 return string_view{*
this}.find_first_of(str, pos);
1647 ARENE_NODISCARD
constexpr auto find_first_of(detail::raw_c_string str)
const noexcept -> size_type {
1648 return find_first_of(string_view{str}, 0U);
1657 ARENE_NODISCARD
constexpr auto find_first_of(detail::raw_c_string str, size_type pos)
const noexcept -> size_type {
1658 return find_first_of(string_view{str}, pos);
1668 ARENE_NODISCARD
constexpr auto find_first_of(detail::raw_c_string str, size_type pos, size_type count)
const noexcept
1670 return find_first_of(string_view{str, count}, pos);
1677 ARENE_NODISCARD
constexpr auto find_first_of(detail::character chr)
const noexcept -> size_type {
return find(chr); }
1685 ARENE_NODISCARD
constexpr auto find_first_of(detail::character chr, size_type pos)
const noexcept -> size_type {
1686 return find(chr, pos);
1694 ARENE_NODISCARD
constexpr auto find_first_not_of(string_view str)
const noexcept -> size_type {
1695 return find_first_not_of(str, 0U);
1704 ARENE_NODISCARD
constexpr auto find_first_not_of(string_view str, size_type pos)
const noexcept -> size_type {
1705 return string_view{*
this}.find_first_not_of(str, pos);
1713 ARENE_NODISCARD
constexpr auto find_first_not_of(detail::raw_c_string str)
const noexcept -> size_type {
1714 return find_first_not_of(string_view{str}, 0U);
1723 ARENE_NODISCARD
constexpr auto find_first_not_of(detail::raw_c_string str, size_type pos)
const noexcept
1725 return find_first_not_of(string_view{str}, pos);
1735 ARENE_NODISCARD
constexpr auto find_first_not_of(detail::raw_c_string str, size_type pos, size_type count)
1736 const noexcept -> size_type {
1737 return find_first_not_of(string_view{str, count}, pos);
1744 ARENE_NODISCARD
constexpr auto find_first_not_of(detail::character chr)
const noexcept -> size_type {
1745 return find_first_not_of(string_view{&chr, 1U});
1754 ARENE_NODISCARD
constexpr auto find_first_not_of(detail::character chr, size_type pos)
const noexcept -> size_type {
1755 return find_first_not_of(string_view{&chr, 1U}, pos);
1762 ARENE_NODISCARD
constexpr auto find_last_of(string_view str)
const noexcept -> size_type {
1763 return find_last_of(str, npos);
1773 ARENE_NODISCARD
constexpr auto find_last_of(string_view str, size_type pos)
const noexcept -> size_type {
1774 return string_view{*
this}.find_last_of(str, pos);
1781 ARENE_NODISCARD
constexpr auto find_last_of(detail::raw_c_string str)
const noexcept -> size_type {
1782 return find_last_of(string_view{str}, npos);
1792 ARENE_NODISCARD
constexpr auto find_last_of(detail::raw_c_string str, size_type pos)
const noexcept -> size_type {
1793 return find_last_of(string_view{str}, pos);
1804 ARENE_NODISCARD
constexpr auto find_last_of(detail::raw_c_string str, size_type pos, size_type count)
const noexcept
1806 return find_last_of(string_view{str, count}, pos);
1813 ARENE_NODISCARD
constexpr auto find_last_of(detail::character chr)
const noexcept -> size_type {
return rfind(chr); }
1821 ARENE_NODISCARD
constexpr auto find_last_of(detail::character chr, size_type pos)
const noexcept -> size_type {
1822 return rfind(chr, pos);
1830 ARENE_NODISCARD
constexpr auto find_last_not_of(string_view str)
const noexcept -> size_type {
1831 return find_last_not_of(str, npos);
1840 ARENE_NODISCARD
constexpr auto find_last_not_of(string_view str, size_type pos)
const noexcept -> size_type {
1841 return string_view{*
this}.find_last_not_of(str, pos);
1849 ARENE_NODISCARD
constexpr auto find_last_not_of(detail::raw_c_string str)
const noexcept -> size_type {
1850 return find_last_not_of(string_view{str});
1859 ARENE_NODISCARD
constexpr auto find_last_not_of(detail::raw_c_string str, size_type pos)
const noexcept -> size_type {
1860 return find_last_not_of(string_view{str}, pos);
1870 ARENE_NODISCARD
constexpr auto find_last_not_of(detail::raw_c_string str, size_type pos, size_type count)
1871 const noexcept -> size_type {
1872 return find_last_not_of(string_view{str, count}, pos);
1879 ARENE_NODISCARD
constexpr auto find_last_not_of(detail::character chr)
const noexcept -> size_type {
1880 return find_last_not_of(string_view{&chr, 1U});
1890 ARENE_NODISCARD
constexpr auto find_last_not_of(detail::character chr, size_type pos)
const noexcept -> size_type {
1891 return find_last_not_of(string_view{&chr, 1U}, pos);
1898 ARENE_NODISCARD
constexpr auto starts_with(detail::character chr)
const noexcept ->
bool {
1899 return string_view{*
this}.starts_with(chr);
1906 ARENE_NODISCARD
constexpr auto starts_with(string_view str)
const noexcept ->
bool {
1907 return string_view{*
this}.starts_with(str);
1914 ARENE_NODISCARD
constexpr auto ends_with(detail::character chr)
const noexcept ->
bool {
1915 return string_view{*
this}.ends_with(chr);
1922 ARENE_NODISCARD
constexpr auto ends_with(string_view str)
const noexcept ->
bool {
1923 return string_view{*
this}.ends_with(str);
1931 ARENE_NODISCARD
constexpr auto compare(string_view other)
const noexcept -> integral_comparison_result {
1932 return string_view{*
this}.compare(other);
1941 ARENE_NODISCARD
constexpr auto compare(size_type pos, size_type count, string_view other)
const noexcept
1942 -> integral_comparison_result {
1943 return string_view{*
this}.substr(pos, count).compare(other);
1954 ARENE_NODISCARD
constexpr auto compare(size_type pos, size_type count, string_view other, size_type pos2)
1955 const noexcept -> integral_comparison_result {
1956 return compare(pos, count, other.substr(pos2));
1968 ARENE_NODISCARD
constexpr auto
1969 compare(size_type pos, size_type length1, string_view other, size_type pos2, size_type length2)
const noexcept
1970 -> integral_comparison_result {
1971 return compare(pos, length1, other.substr(pos2, length2));
1981 ARENE_NODISCARD
constexpr auto
1982 compare(size_type pos, size_type length1, detail::raw_c_string other, size_type length2)
const noexcept
1983 -> integral_comparison_result {
1984 return compare(pos, length1, string_view{other, length2});
1993 template <std::size_t OtherMaxLength>
1994 ARENE_NODISCARD
friend constexpr auto
1995 operator+(inline_string
const& lhs, inline_string<OtherMaxLength>
const& rhs)
noexcept
1996 -> inline_string<MaxSize + OtherMaxLength> {
1997 inline_string<MaxSize + OtherMaxLength> res{lhs};
1998 std::ignore = res.append(rhs);
2011 ARENE_NODISCARD
friend constexpr auto operator+(inline_string
const& lhs, string_view
const rhs)
noexcept
2013 ARENE_PRECONDITION(lhs.size() + rhs.size() <= lhs.max_size());
2014 inline_string res{lhs};
2015 std::ignore = res.append(rhs);
2029 ARENE_NODISCARD
friend constexpr auto operator+(string_view
const lhs, inline_string
const& rhs)
noexcept
2031 ARENE_PRECONDITION(lhs.size() + rhs.size() <= rhs.max_size());
2032 inline_string res{lhs};
2033 std::ignore = res.append(rhs);
2047 template <
typename Itr>
2048 static constexpr auto do_try_construct(std::random_access_iterator_tag, Itr first, Itr last)
noexcept
2049 -> optional<inline_string> {
2050 if (::arene::base::distance(first, last) >
static_cast<difference_type>(MaxSize)) {
2053 return {inline_string{first, last}};
2063 template <
typename Itr>
2064 static constexpr auto do_try_construct(std::input_iterator_tag, Itr first, Itr last)
noexcept
2065 -> optional<inline_string> {
2067 while ((str.size() < str.max_size()) && (first != last)) {
2068 str.push_back(*(first++));
2070 if (first != last) {
2083 template <
typename Itr>
2084 constexpr auto do_insert(std::input_iterator_tag, const_iterator pos, Itr first, Itr last) -> iterator {
2085 auto const offset = pos - cbegin();
2086 std::ignore = insert(
static_cast<size_type>(offset), inline_string{first, last});
2087 return begin() + offset;
2096 template <
typename Itr>
2097 constexpr auto do_insert(std::random_access_iterator_tag, const_iterator pos, Itr first, Itr last) -> iterator {
2098 auto const offset = pos - cbegin();
2099 auto const distance = last - first;
2100 ARENE_PRECONDITION(distance >= 0);
2101 auto const insertion_location = prepare_insert(
static_cast<size_type>(offset),
static_cast<size_type>(distance));
2102 std::ignore = ::arene::base::copy(first, last, insertion_location);
2103 return insertion_location;
2111 constexpr void copy_from_unchecked(string_view str)
noexcept {
2112 std::ignore = arene::base::copy(str.begin(), str.end(), begin());
2113 set_null_terminator_to(str.size());
2122 constexpr void copy_from(string_view str)
noexcept {
2123 ARENE_PRECONDITION(str.size() <= MaxSize);
2124 copy_from_unchecked(str);
2133 template <std::size_t SourceMaxLength, constraints<std::enable_if_t<SourceMaxLength <= MaxSize>> =
nullptr>
2134 constexpr void copy_from(inline_string<SourceMaxLength> str)
noexcept {
2135 copy_from_unchecked(string_view(str));
2145 template <std::size_t SourceMaxLength, constraints<std::enable_if_t<(SourceMaxLength > MaxSize)>> =
nullptr>
2146 constexpr void copy_from(inline_string<SourceMaxLength> str)
noexcept {
2147 copy_from(string_view(str));
2158 constexpr void copy_from(detail::raw_c_string str)
noexcept {
2159 ARENE_PRECONDITION(str !=
nullptr);
2160 copy_from(string_view{str});
2171 template <
typename Itr>
2172 constexpr void copy_from(std::input_iterator_tag, Itr first, Itr last)
noexcept {
2173 for (
auto const chr : make_subrange(first, last)) {
2185 template <
typename Itr>
2186 constexpr void copy_from(std::random_access_iterator_tag, Itr first, Itr last)
noexcept {
2187 auto const source_length = ::arene::base::distance(first, last);
2188 ARENE_PRECONDITION(source_length >= 0);
2189 auto const usource_length =
static_cast<size_type>(source_length);
2190 ARENE_PRECONDITION(usource_length <= max_size());
2191 std::ignore = ::arene::base::copy(first, last, begin());
2192 set_null_terminator_to(usource_length);
2208 constexpr auto prepare_insert(size_type pos, size_type insertion_length)
noexcept -> iterator {
2209 ARENE_PRECONDITION(pos <=
this->size());
2210 ARENE_PRECONDITION(max_size() -
this->size() >= insertion_length);
2211 std::ignore = ::arene::base::copy(
2213 rbegin() +
static_cast<std::ptrdiff_t>(
this->size() - pos),
2214 rbegin() -
static_cast<std::ptrdiff_t>(insertion_length)
2216 set_null_terminator_to(
this->size() + insertion_length);
2217 return begin() +
static_cast<difference_type>(pos);
2231 constexpr void prepare_replace(size_type pos, size_type original_length, size_type replacement_length) {
2232 ARENE_PRECONDITION(pos <=
this->size());
2233 auto const removal_length = std::min(original_length,
this->size() - pos);
2234 ARENE_PRECONDITION(
this->size() - removal_length + replacement_length <= MaxSize);
2235 if (removal_length > replacement_length) {
2236 std::ignore = erase(pos + replacement_length, removal_length - replacement_length);
2238 std::ignore = prepare_insert(pos + removal_length, replacement_length - removal_length);
2247 constexpr void set_null_terminator_to(size_type pos) {
2248 this->set_size(pos);
2249 buffer_[
this->size()] =
'\0';
2253 arene::base::array<detail::character, MaxSize + 1> buffer_{};