5#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_STRINGS_INLINE_STRING_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_STRINGS_INLINE_STRING_HPP_
22#include "arene/base/detail/exceptions.hpp"
23#include "arene/base/detail/raw_c_string.hpp"
24#include "arene/base/detail/wrapped_iterator.hpp"
28#include "arene/base/stdlib_choice/cstddef.hpp"
29#include "arene/base/stdlib_choice/enable_if.hpp"
30#include "arene/base/stdlib_choice/ignore.hpp"
31#include "arene/base/stdlib_choice/initializer_list.hpp"
32#include "arene/base/stdlib_choice/integral_constant.hpp"
33#include "arene/base/stdlib_choice/iterator_tags.hpp"
34#include "arene/base/stdlib_choice/iterator_traits.hpp"
35#include "arene/base/stdlib_choice/min_value_overload.hpp"
36#include "arene/base/stdlib_choice/numeric_limits.hpp"
37#include "arene/base/stdlib_choice/remove_cv.hpp"
38#include "arene/base/strings/detail/inline_string_std_string_mixin.hpp"
52namespace inline_string_detail {
57class inline_string_base {
64 class iterator_passkey {
67 constexpr explicit iterator_passkey() noexcept = default;
72 constexpr inline_string_base() = default;
74 constexpr inline_string_base(inline_string_base const&) = default;
76 constexpr inline_string_base(inline_string_base&&) = default;
78 constexpr auto operator=(inline_string_base const&) -> inline_string_base& = default;
80 constexpr auto operator=(inline_string_base&&) -> inline_string_base& = default;
82 ~inline_string_base() = default;
87 using value_type = detail::character;
89 using reference = value_type&;
91 using const_reference = value_type const&;
93 using pointer = value_type*;
95 using const_pointer = value_type const*;
97 using iterator = ::arene::base::detail::wrapped_iterator<pointer, iterator_passkey>;
99 using const_iterator = ::arene::base::detail::wrapped_iterator<const_pointer, iterator_passkey>;
101 using reverse_iterator = ::arene::base::reverse_iterator<iterator>;
103 using const_reverse_iterator = ::arene::base::reverse_iterator<const_iterator>;
105 using difference_type = typename iterator::difference_type;
112 constexpr auto size() const noexcept -> size_type {
return string_length_; }
118 constexpr auto length() const noexcept -> size_type {
return size(); }
129 static constexpr auto common_fast_inequality_check(inline_string_base
const& lhs, string_view
const& rhs)
noexcept
141 constexpr void set_size(size_type
const new_size)
noexcept { string_length_ = new_size; }
145 size_type string_length_{0U};
156template <std::
size_t MaxSize>
159 :
public inline_string_detail::inline_string_base
160 ,
public detail::mixin_at<inline_string<MaxSize>, typename inline_string_detail::inline_string_base::size_type>
161 , inline_string_std_string_mixin<inline_string<MaxSize>>
168 using integral_comparison_result = int;
176 "Must have ability to get difference between iterators"
181 using typename inline_string_base::size_type;
182 using typename inline_string_base::value_type;
184 using typename inline_string_base::const_reference;
185 using typename inline_string_base::reference;
187 using typename inline_string_base::const_pointer;
188 using typename inline_string_base::pointer;
190 using typename inline_string_base::const_iterator;
191 using typename inline_string_base::const_reverse_iterator;
192 using typename inline_string_base::iterator;
193 using typename inline_string_base::reverse_iterator;
246 template <std::
size_t N>
250 static_assert(N - 1UL <= MaxSize,
"String literal must fit into MaxLength");
254 auto const first_nul_idx = as_view.
find(
'\0');
256 as_view = as_view.substr(0UL, first_nul_idx);
259 copy_from_unchecked(as_view);
289 if (str.length() > MaxSize) {
305 template <
size_type OtherMaxLength, constra
ints<std::enable_if_t<(OtherMaxLength <= MaxSize)>> =
nullptr>
307 constexpr inline_
string(inline_
string<OtherMaxLength> const& other) noexcept
322 template <
size_type OtherMaxLength, constra
ints<std::enable_if_t<(OtherMaxLength > MaxSize)>> =
nullptr>
353 template <
size_type OtherMaxSize, constra
ints<std::enable_if_t<(OtherMaxSize <= MaxSize)>> =
nullptr>
362 template <
size_type OtherMaxSize, constra
ints<std::enable_if_t<(OtherMaxSize > MaxSize)>> =
nullptr>
364 if (str.length() > MaxSize) {
379 template <
typename InputIterator, constra
ints<std::enable_if_t<is_input_iterator_v<InputIterator>>> =
nullptr>
381 InputIterator
const first,
382 InputIterator
const last
397 template <
typename InputIterator, constra
ints<std::enable_if_t<is_input_iterator_v<InputIterator>>> =
nullptr>
398 static constexpr auto
401 return inline_string::do_try_construct(
490 template <std::
size_t OtherMaxLength>
526 return assign(str.substr(pos, count));
599 return insert(pos1, str.substr(pos2));
614 return insert(pos1, str.substr(pos2, length2));
628 constexpr auto insert(size_type pos, detail::raw_c_string str, size_type count)
noexcept ->
inline_string& {
644 auto const insert_begin = prepare_insert(pos, count);
645 ::arene::base::fill(insert_begin, insert_begin +
static_cast<difference_type
>(count), chr);
658 constexpr auto insert(const_iterator pos, detail::character chr)
noexcept -> iterator {
return insert(pos, 1U, chr); }
671 constexpr auto insert(const_iterator pos, size_type count, detail::character chr)
noexcept -> iterator {
672 auto const offset = pos -
cbegin();
674 return begin() + offset;
687 auto const offset = pos -
cbegin();
689 return begin() + offset;
703 template <
typename InputIterator, constra
ints<std::enable_if_t<base::is_input_iterator_v<InputIterator>>> =
nullptr>
725 return erase(pos, this->size() - pos);
737 if (pos < this->size()) {
738 count =
std::min(count, this->size() - pos);
740 size_type
const erase_end{pos + count};
742 begin() +
static_cast<difference_type
>(erase_end),
744 begin() +
static_cast<difference_type
>(pos)
746 set_null_terminator_to(this->size() - count);
757 constexpr auto erase(const_iterator pos)
noexcept -> iterator {
758 auto const offset = pos -
cbegin();
759 ARENE_PRECONDITION((offset >= 0) && (
static_cast<size_type
>(offset) <= this->size()));
761 return begin() + offset;
771 constexpr auto erase(const_iterator first, const_iterator last)
noexcept -> iterator {
773 auto const offset = first -
cbegin();
775 std::ignore =
erase(
static_cast<size_type
>(offset),
static_cast<size_type
>(last - first));
776 return begin() + offset;
792 prepare_replace(pos, count, str.length());
813 return replace(pos, count, str.substr(pos2));
832 constexpr auto replace(size_type pos, size_type count,
string_view str, size_type pos2, size_type count2)
noexcept
834 return replace(pos, count, str.substr(pos2, count2));
852 constexpr auto replace(size_type pos, size_type count, detail::raw_c_string str, size_type count2)
noexcept
872 constexpr auto replace(size_type pos, size_type count, size_type count2, detail::character chr)
noexcept
874 prepare_replace(pos, count, count2);
875 auto const fill_begin =
begin() +
static_cast<difference_type
>(pos);
896 auto const offset = first -
cbegin();
898 return replace(
static_cast<size_type
>(offset),
static_cast<size_type
>(last - first), str);
917 constexpr auto replace(const_iterator first, const_iterator last,
string_view str, size_type pos)
noexcept
919 return replace(first, last, str.substr(pos));
940 replace(const_iterator first, const_iterator last,
string_view str, size_type pos, size_type count)
noexcept
942 return replace(first, last, str.substr(pos, count));
962 constexpr auto replace(const_iterator first, const_iterator last, detail::raw_c_string str, size_type count)
noexcept
982 constexpr auto replace(const_iterator first, const_iterator last, size_type count, detail::character chr)
noexcept
985 auto const offset = first -
cbegin();
987 return replace(
static_cast<size_type
>(offset),
static_cast<size_type
>(last - first), count, chr);
1027 typename InputIterator,
1032 const_iterator first,
1033 const_iterator last,
1034 InputIterator first2,
1056 typename RandomAccessIterator,
1059 const_iterator first,
1060 const_iterator last,
1061 RandomAccessIterator first2,
1062 RandomAccessIterator last2
1064 auto const length_of_replacement = last2 - first2;
1067 auto const offset = first -
cbegin();
1069 inline_string::size_type pos{
static_cast<inline_string::size_type
>(offset)};
1072 static_cast<inline_string::size_type
>(last - first),
1073 static_cast<inline_string::size_type
>(length_of_replacement)
1093 constexpr auto copy(detail::character* str, size_type count)
const -> size_type {
1105 constexpr auto copy(detail::character* str, size_type count, size_type pos)
const -> size_type {
1168 constexpr void clear() noexcept { set_null_terminator_to(0U); }
1178 constexpr void resize(size_type new_size, detail::character new_char =
'\0') noexcept {
1180 inline_string::iterator original_end{
end()};
1181 set_null_terminator_to(new_size);
1193 return buffer_[index];
1204 return buffer_[index];
1214 return buffer_.front();
1223 return buffer_.front();
1232 return buffer_[this->size() - 1U];
1241 return buffer_[this->size() - 1U];
1250 return iterator(iterator_passkey{}, buffer_.begin().
base());
1258 return const_iterator(iterator_passkey{}, buffer_.begin().
base());
1272 return begin() +
static_cast<difference_type
>(this->size());
1279 return begin() +
static_cast<difference_type
>(this->size());
1326 template <std::
size_t OtherMaxLength>
1375 template <std::
size_t OtherMaxLength>
1390 return inline_string_base::common_fast_inequality_check(lhs, rhs);
1404 set_null_terminator_to(this->size() + rhs.size());
1448 return append(rhs.substr(pos, count));
1474 resize(this->size() + count, chr);
1718 return find(chr, pos);
1768 const noexcept -> size_type {
1854 return rfind(chr, pos);
1903 const noexcept -> size_type {
1974 -> integral_comparison_result {
1987 const noexcept -> integral_comparison_result {
1988 return compare(pos, count, other.substr(pos2));
2001 compare(size_type pos, size_type length1,
string_view other, size_type pos2, size_type length2)
const noexcept
2002 -> integral_comparison_result {
2003 return compare(pos, length1, other.substr(pos2, length2));
2014 compare(size_type pos, size_type length1, detail::raw_c_string other, size_type length2)
const noexcept
2015 -> integral_comparison_result {
2025 template <std::
size_t OtherMaxLength>
2079 template <
typename Itr>
2085 return {inline_string{first, last}};
2095 template <
typename Itr>
2096 static constexpr auto do_try_construct(std::input_iterator_tag, Itr first, Itr last)
noexcept
2097 -> optional<inline_string> {
2099 while ((str.size() < str.max_size()) && (first != last)) {
2100 str.push_back(*(first++));
2102 if (first != last) {
2115 template <
typename Itr>
2116 constexpr auto do_insert(std::input_iterator_tag, const_iterator pos, Itr first, Itr last) -> iterator {
2117 auto const offset = pos -
cbegin();
2118 std::ignore = insert(
static_cast<size_type
>(offset), inline_string{first, last});
2119 return begin() + offset;
2128 template <
typename Itr>
2129 constexpr auto do_insert(std::random_access_iterator_tag, const_iterator pos, Itr first, Itr last) -> iterator {
2130 auto const offset = pos -
cbegin();
2131 auto const distance = last - first;
2133 auto const insertion_location = prepare_insert(
static_cast<size_type
>(offset),
static_cast<size_type
>(distance));
2135 return insertion_location;
2143 constexpr void copy_from_unchecked(string_view str)
noexcept {
2145 set_null_terminator_to(str.size());
2154 constexpr void copy_from(string_view str)
noexcept {
2156 copy_from_unchecked(str);
2165 template <std::
size_t SourceMaxLength, constra
ints<std::enable_if_t<SourceMaxLength <= MaxSize>> =
nullptr>
2166 constexpr
void copy_from(inline_
string<SourceMaxLength> str) noexcept {
2167 copy_from_unchecked(
string_view(str));
2177 template <std::
size_t SourceMaxLength, constra
ints<std::enable_if_t<(SourceMaxLength > MaxSize)>> =
nullptr>
2178 constexpr void copy_from(inline_string<SourceMaxLength> str)
noexcept {
2179 copy_from(string_view(str));
2190 constexpr void copy_from(detail::raw_c_string str)
noexcept {
2192 copy_from(string_view{str});
2203 template <
typename Itr>
2204 constexpr void copy_from(std::input_iterator_tag, Itr first, Itr last)
noexcept {
2217 template <
typename Itr>
2218 constexpr void copy_from(std::random_access_iterator_tag, Itr first, Itr last)
noexcept {
2221 auto const usource_length =
static_cast<size_type
>(source_length);
2224 set_null_terminator_to(usource_length);
2240 constexpr auto prepare_insert(size_type pos, size_type insertion_length)
noexcept -> iterator {
2248 set_null_terminator_to(this->size() + insertion_length);
2249 return begin() +
static_cast<difference_type
>(pos);
2263 constexpr void prepare_replace(size_type pos, size_type original_length, size_type replacement_length) {
2265 auto const removal_length =
std::min(original_length, this->size() - pos);
2267 if (removal_length > replacement_length) {
2268 std::ignore = erase(pos + replacement_length, removal_length - replacement_length);
2270 std::ignore = prepare_insert(pos + removal_length, replacement_length - removal_length);
2279 constexpr void set_null_terminator_to(size_type pos) {
2280 this->set_size(pos);
2281 buffer_[this->size()] =
'\0';
2285 arene::base::array<detail::character, MaxSize + 1> buffer_{};
2289template <std::
size_t MaxLength>
2292namespace inline_string_detail {
2296template <
typename Type,
typename = constra
ints<>>
2301template <std::
size_t Capacity>
2310template <
typename Type>
2311extern constexpr bool is_inline_string_v = inline_string_detail::is_inline_string_v<std::remove_cv_t<Type>>;
2318template <
typename Type>
2325template <
typename Type>
2333template <
typename Type>
2336namespace inline_string_detail {
2339class make_inline_string_impl_fn {
2347 template <std::
size_t N, constra
ints<std::enable_if_t<N != 0>> =
nullptr>
2349 constexpr auto operator()(detail::character
const (&str)[N])
const noexcept ->
inline_string<N - 1U> {
#define ARENE_CPP14_INLINE_VARIABLE(type, name)
Emulates C++17's inline variable declarations for function objects.
Definition cpp14_inline.hpp:69
constexpr generic_ordering_from_three_way_compare() noexcept=default
A string type with a fixed maximum capacity, where the data is stored internally without allocations.
Definition inline_string.hpp:162
static ARENE_NODISCARD constexpr auto fast_inequality_check(inline_string const &lhs, inline_string< OtherMaxLength > const &rhs) noexcept -> inequality_heuristic
Determine if two strings are definitely not equal.
Definition inline_string.hpp:1377
ARENE_NODISCARD constexpr auto back() noexcept -> detail::character &
Get the last character in the string.
Definition inline_string.hpp:1239
constexpr auto erase() noexcept -> inline_string &
Erase all the characters in the string.
Definition inline_string.hpp:714
constexpr auto append(size_type count, detail::character chr) noexcept -> inline_string &
Append the specified number of copies of a character to the string.
Definition inline_string.hpp:1473
ARENE_NODISCARD constexpr auto rbegin() noexcept -> reverse_iterator
Return an iterator to the start of the reversed string.
Definition inline_string.hpp:1290
constexpr inline_string() noexcept=default
Default-construct an empty string.
constexpr auto erase(const_iterator pos) noexcept -> iterator
Erase the character at the specified range.
Definition inline_string.hpp:757
static ARENE_NODISCARD constexpr auto fast_inequality_check(inline_string const &lhs, string_view rhs) noexcept -> inequality_heuristic
Determine if two strings are definitely not equal.
Definition inline_string.hpp:1388
ARENE_NODISCARD auto rbegin() const noexcept -> const_reverse_iterator
Return an iterator to the start of the reversed string.
Definition inline_string.hpp:1295
ARENE_NODISCARD constexpr auto find_last_of(detail::character chr) const noexcept -> size_type
Find the latest position such that the character at that position is the provided character.
Definition inline_string.hpp:1845
constexpr void clear() noexcept
Definition inline_string.hpp:1168
ARENE_NODISCARD constexpr auto find_last_of(string_view str) const noexcept -> size_type
Find the last position such that the character at that position is one of those in the provided strin...
Definition inline_string.hpp:1794
ARENE_NODISCARD constexpr auto rfind(detail::raw_c_string str, size_type pos) const noexcept -> size_type
Find the latest position of the given substring within the string, starting at the specified position...
Definition inline_string.hpp:1641
ARENE_NODISCARD constexpr auto find_last_of(string_view str, size_type pos) const noexcept -> size_type
Find the last position from the provided start position backwards such that the character at that pos...
Definition inline_string.hpp:1805
ARENE_NODISCARD constexpr auto find(detail::raw_c_string str, size_type pos, size_type count) const noexcept -> size_type
Find the earliest position of the n character string starting at str within the string,...
Definition inline_string.hpp:1591
ARENE_NODISCARD constexpr auto find_first_not_of(string_view str, size_type pos) const noexcept -> size_type
Find the earliest position from the provided start position onwards such that the character at that p...
Definition inline_string.hpp:1736
constexpr auto insert(size_type pos1, string_view str, size_type pos2) noexcept -> inline_string &
Insert the substring of the supplied string starting from pos2 at pos1.
Definition inline_string.hpp:598
ARENE_NODISCARD constexpr auto find_first_not_of(detail::raw_c_string str) const noexcept -> size_type
Find the earliest position such that the character at that position is not one of those in the provid...
Definition inline_string.hpp:1745
constexpr auto operator=(detail::raw_c_string str) noexcept -> inline_string &
Assign from a nul-terminated string.
Definition inline_string.hpp:448
static ARENE_NODISCARD constexpr auto three_way_compare(inline_string const &lhs, detail::raw_c_string rhs) noexcept -> strong_ordering
Compare two strings for lexicographical ordering.
Definition inline_string.hpp:1351
ARENE_NODISCARD constexpr auto front() noexcept -> detail::character &
Get the first character in the string.
Definition inline_string.hpp:1221
ARENE_NODISCARD constexpr auto find_last_of(detail::raw_c_string str, size_type pos) const noexcept -> size_type
Find the last position from the provided start position backwards such that the character at that pos...
Definition inline_string.hpp:1824
ARENE_NODISCARD constexpr auto find(detail::character chr) const noexcept -> size_type
Find the earliest position of the specified character within the string.
Definition inline_string.hpp:1554
ARENE_NODISCARD constexpr auto substr(size_type pos, size_type n) const noexcept -> inline_string
Produce a substring of the string with an offset and length.
Definition inline_string.hpp:1128
ARENE_NODISCARD constexpr auto find_last_not_of(detail::character chr) const noexcept -> size_type
Find the latest position such that the character at that position is not the provided character.
Definition inline_string.hpp:1911
ARENE_NODISCARD constexpr auto ends_with(detail::character chr) const noexcept -> bool
Check if the string ends with a character.
Definition inline_string.hpp:1946
constexpr inline_string(InputIterator const first, InputIterator const last) noexcept(denotes_nothrow_iterable_range_v< InputIterator >)
Construction from a sequence of characters represented as a pair of iterators.
Definition inline_string.hpp:380
constexpr auto append(string_view rhs, size_type pos, size_type count) noexcept -> inline_string &
Append a substring of a string to the current string.
Definition inline_string.hpp:1447
ARENE_NODISCARD constexpr auto starts_with(detail::character chr) const noexcept -> bool
Check if the string starts with a character.
Definition inline_string.hpp:1930
ARENE_NODISCARD friend constexpr auto operator+(inline_string const &lhs, string_view const rhs) noexcept -> inline_string
Concatenate two strings.
Definition inline_string.hpp:2043
ARENE_NODISCARD constexpr auto find_first_not_of(detail::character chr, size_type pos) const noexcept -> size_type
Find the earliest position from the provided start position onwards such that the character at that p...
Definition inline_string.hpp:1786
ARENE_NODISCARD constexpr auto data() const noexcept -> detail::raw_c_string
Definition inline_string.hpp:1146
static ARENE_NODISCARD constexpr auto three_way_compare(inline_string const &lhs, string_view rhs) noexcept -> strong_ordering
Compare two strings for lexicographical ordering.
Definition inline_string.hpp:1339
constexpr inline_string(detail::character const (&str)[N]) noexcept
Construct from the source string literal.
Definition inline_string.hpp:248
ARENE_NODISCARD constexpr auto compare(size_type pos, size_type length1, string_view other, size_type pos2, size_type length2) const noexcept -> integral_comparison_result
Compare a substring against a substring of another string, to see if it is less than,...
Definition inline_string.hpp:2001
ARENE_NODISCARD constexpr auto find_last_of(detail::character chr, size_type pos) const noexcept -> size_type
Find the latest position from the provided start position backwards such that the character at that p...
Definition inline_string.hpp:1853
ARENE_NODISCARD constexpr auto begin() const noexcept -> const_iterator
Iterator to the first position in the string.
Definition inline_string.hpp:1257
constexpr auto replace(const_iterator first, const_iterator last, detail::raw_c_string str, size_type count) noexcept -> inline_string &
Replace a substring with a c-string.
Definition inline_string.hpp:962
constexpr auto operator=(inline_string &&) -> inline_string &=default
Default move assignment.
static constexpr auto capacity() -> std::size_t
The maximum length of the string.
Definition inline_string.hpp:1156
ARENE_NODISCARD constexpr auto find_last_not_of(detail::raw_c_string str, size_type pos) const noexcept -> size_type
Find the latest position from the provided start position backwards such that the character at that p...
Definition inline_string.hpp:1891
ARENE_NODISCARD constexpr auto find_first_of(detail::raw_c_string str) const noexcept -> size_type
Find the earliest position such that the character at that position is one of those in the provided s...
Definition inline_string.hpp:1679
ARENE_NODISCARD constexpr auto cend() const noexcept -> const_iterator
Return an iterator to one-past-the-last position in the string.
Definition inline_string.hpp:1284
ARENE_NODISCARD constexpr auto rfind(string_view str, size_type pos) const noexcept -> size_type
Find the latest position of the given substring within the string, starting at the specified position...
Definition inline_string.hpp:1607
ARENE_NODISCARD constexpr auto find_first_of(detail::raw_c_string str, size_type pos) const noexcept -> size_type
Find the earliest position from the provided start position onwards such that the character at that p...
Definition inline_string.hpp:1689
constexpr auto insert(size_type pos, detail::raw_c_string str, size_type count) noexcept -> inline_string &
Insert the string of count characters starting at str at pos.
Definition inline_string.hpp:628
constexpr auto operator=(string_view str) noexcept -> inline_string &
Assign from a string_view.
Definition inline_string.hpp:433
ARENE_NODISCARD constexpr auto begin() noexcept -> iterator
Definition inline_string.hpp:1249
static constexpr auto try_construct(InputIterator first, InputIterator last) noexcept(denotes_nothrow_iterable_range_v< InputIterator >) -> optional< inline_string >
Attempt to construct from a sequence of characters.
Definition inline_string.hpp:399
constexpr void push_back(detail::character rhs) noexcept
Append a character to the current string.
Definition inline_string.hpp:1484
ARENE_NODISCARD constexpr auto find_last_not_of(detail::character chr, size_type pos) const noexcept -> size_type
Find the latest position from the provided start position backwards such that the character at that p...
Definition inline_string.hpp:1922
ARENE_NODISCARD constexpr auto compare(size_type pos, size_type count, string_view other) const noexcept -> integral_comparison_result
Compare a substring against another string, to see if it is less than, equal to or greater than the o...
Definition inline_string.hpp:1973
constexpr auto assign(string_view str, size_type pos, size_type count) noexcept -> inline_string &
Assign from a substring of a string_view starting at the specified position, with the specified max l...
Definition inline_string.hpp:525
constexpr void resize(size_type new_size, detail::character new_char='\0') noexcept
Definition inline_string.hpp:1178
ARENE_NODISCARD auto rend() const noexcept -> const_reverse_iterator
Return an iterator to the end of the reversed string.
Definition inline_string.hpp:1310
ARENE_NODISCARD constexpr auto find(detail::character chr, size_type pos) const noexcept -> size_type
Find the earliest position of the specified character within the string, starting at the specified po...
Definition inline_string.hpp:1563
constexpr inline_string(size_type len, detail::character chr) noexcept
Construct a pre-filled inline_string of a given length.
Definition inline_string.hpp:339
ARENE_NODISCARD constexpr auto starts_with(string_view str) const noexcept -> bool
Check if the string starts with another string.
Definition inline_string.hpp:1938
constexpr auto append(detail::raw_c_string rhs, size_type count) noexcept -> inline_string &
Append a string specified as pointer and length to the current string.
Definition inline_string.hpp:1459
ARENE_NODISCARD constexpr auto find_first_of(string_view str) const noexcept -> size_type
Find the earliest position such that the character at that position is one of those in the provided s...
Definition inline_string.hpp:1661
constexpr auto insert(const_iterator pos, InputIterator first, InputIterator last) noexcept(denotes_nothrow_iterable_range_v< InputIterator >) -> iterator
Insert a series of characters from an iterator range into the string at the specified position.
Definition inline_string.hpp:704
constexpr auto replace(const_iterator first, const_iterator last, string_view str) noexcept -> inline_string &
Replace a substring with another string.
Definition inline_string.hpp:894
constexpr auto operator+=(string_view rhs) noexcept -> inline_string &
Append a string to the current string.
Definition inline_string.hpp:1493
ARENE_NODISCARD constexpr auto rfind(string_view str) const noexcept -> size_type
Find the latest position of the given substring within the string.
Definition inline_string.hpp:1600
constexpr auto assign(string_view str, size_type pos) noexcept -> inline_string &
Assign from a string_view.
Definition inline_string.hpp:514
ARENE_NODISCARD constexpr auto find_first_not_of(detail::raw_c_string str, size_type pos) const noexcept -> size_type
Find the earliest position from the provided start position onwards such that the character at that p...
Definition inline_string.hpp:1755
static ARENE_NODISCARD constexpr auto three_way_compare(inline_string const &lhs, inline_string< OtherMaxLength > const &rhs) noexcept -> strong_ordering
Compare two strings for lexicographical ordering.
Definition inline_string.hpp:1328
constexpr auto replace(size_type pos, size_type count, size_type count2, detail::character chr) noexcept -> inline_string &
Replace a substring with repeated copies of a given character.
Definition inline_string.hpp:872
constexpr auto operator=(std::initializer_list< detail::character > str) noexcept -> inline_string &
Assign from an initializer list.
Definition inline_string.hpp:462
constexpr auto erase(size_type pos, size_type count) noexcept -> inline_string &
Erase the specified number of characters in the string starting at the specified position.
Definition inline_string.hpp:736
constexpr auto assign(detail::character chr) noexcept -> inline_string &
Assign from a single character.
Definition inline_string.hpp:559
ARENE_NODISCARD constexpr auto find_first_of(detail::character chr) const noexcept -> size_type
Find the earliest position such that the character at that position is the provided character.
Definition inline_string.hpp:1709
constexpr auto operator+=(detail::character rhs) noexcept -> inline_string &
Append a character to the current string.
Definition inline_string.hpp:1502
ARENE_NODISCARD constexpr auto find_first_not_of(detail::raw_c_string str, size_type pos, size_type count) const noexcept -> size_type
Find the earliest position from the provided start position onwards such that the character at that p...
Definition inline_string.hpp:1767
static constexpr auto try_construct(string_view const str) noexcept -> optional< inline_string >
Attempt to construct from a string_view .
Definition inline_string.hpp:288
ARENE_NODISCARD constexpr auto find_last_of(detail::raw_c_string str) const noexcept -> size_type
Find the last position such that the character at that position is one of those in the provided strin...
Definition inline_string.hpp:1813
ARENE_NODISCARD auto crbegin() const noexcept -> const_reverse_iterator
Return an iterator to the start of the reversed string.
Definition inline_string.hpp:1300
constexpr void pop_back() noexcept
Remove the last character.
Definition inline_string.hpp:1082
ARENE_NODISCARD constexpr auto find_first_of(detail::raw_c_string str, size_type pos, size_type count) const noexcept -> size_type
Find the earliest position from the provided start position onwards such that the character at that p...
Definition inline_string.hpp:1700
ARENE_NODISCARD constexpr auto find_last_not_of(string_view str, size_type pos) const noexcept -> size_type
Find the latest position from the provided start position backwards such that the character at that p...
Definition inline_string.hpp:1872
constexpr auto append(string_view rhs, size_type pos) noexcept -> inline_string &
Append a substring of a string to the current string.
Definition inline_string.hpp:1436
constexpr auto insert(size_type pos, string_view str) noexcept -> inline_string &
Insert the supplied string at the specified position.
Definition inline_string.hpp:583
constexpr auto operator=(inline_string< OtherMaxLength > const &other) noexcept -> inline_string &
Assign from another string.
Definition inline_string.hpp:491
~inline_string()=default
Use the default destructor.
constexpr auto insert(const_iterator pos, size_type count, detail::character chr) noexcept -> iterator
Insert count copies of a character into the string at the specified position.
Definition inline_string.hpp:671
ARENE_NODISCARD constexpr auto rfind(detail::raw_c_string str) const noexcept -> size_type
Find the latest position of the given substring within the string.
Definition inline_string.hpp:1632
static ARENE_NODISCARD constexpr auto three_way_compare(inline_string const &lhs, null_terminated_string_view rhs) noexcept -> strong_ordering
Compare two strings for lexicographical ordering.
Definition inline_string.hpp:1364
constexpr auto replace(size_type pos, size_type count, string_view str, size_type pos2) noexcept -> inline_string &
Replace a substring with another substring.
Definition inline_string.hpp:812
constexpr auto operator+=(std::initializer_list< detail::character > rhs) noexcept -> inline_string &
Append a series of characters from an initializer list to the string.
Definition inline_string.hpp:1511
ARENE_NODISCARD constexpr auto substr() const noexcept -> inline_string
Produce a copy of the string.
Definition inline_string.hpp:1111
ARENE_NODISCARD friend constexpr auto operator+(string_view const lhs, inline_string const &rhs) noexcept -> inline_string
Concatenate two strings.
Definition inline_string.hpp:2061
constexpr auto insert(size_type pos, size_type count, detail::character chr) noexcept -> inline_string &
Insert count copies of the specified character starting at position pos.
Definition inline_string.hpp:643
ARENE_NODISCARD auto crend() const noexcept -> const_reverse_iterator
Return an iterator to the end of the reversed string.
Definition inline_string.hpp:1315
ARENE_NODISCARD constexpr auto find_first_not_of(string_view str) const noexcept -> size_type
Find the earliest position such that the character at that position is not one of those in the provid...
Definition inline_string.hpp:1726
ARENE_NODISCARD constexpr auto operator[](size_type index) noexcept -> detail::character &
Retrieve the index -th character in the string.
Definition inline_string.hpp:1202
ARENE_NODISCARD constexpr auto rend() noexcept -> reverse_iterator
Return an iterator to the end of the reversed string.
Definition inline_string.hpp:1305
static constexpr auto try_construct(inline_string< OtherMaxSize > const &str) noexcept -> optional< inline_string >
Attempt to construct from another inline_string with a larger capacity.
Definition inline_string.hpp:363
ARENE_NODISCARD constexpr auto rfind(detail::character chr) const noexcept -> size_type
Find the latest position of the specified character within the string.
Definition inline_string.hpp:1615
constexpr auto copy(detail::character *str, size_type count) const -> size_type
Copy the string into the specified buffer up to the specified maximum length.
Definition inline_string.hpp:1093
ARENE_NODISCARD constexpr auto rfind(detail::character chr, size_type pos) const noexcept -> size_type
Find the latest position of the specified character within the string, starting at the specified posi...
Definition inline_string.hpp:1624
ARENE_NODISCARD constexpr auto ends_with(string_view str) const noexcept -> bool
Check if the string ends with another string.
Definition inline_string.hpp:1954
ARENE_NODISCARD constexpr auto operator[](size_type index) const noexcept -> detail::character const &
Retrieve the index -th character in the string.
Definition inline_string.hpp:1191
constexpr auto append(string_view rhs) noexcept -> inline_string &
Append a string to the current string.
Definition inline_string.hpp:1401
ARENE_NODISCARD constexpr auto end() const noexcept -> const_iterator
Return an iterator to one-past-the-last position in the string.
Definition inline_string.hpp:1278
ARENE_NODISCARD constexpr auto find(string_view str, size_type pos=0U) const noexcept -> size_type
Find the earliest position of the given substring within the string, starting at the specified positi...
Definition inline_string.hpp:1546
constexpr inline_string(inline_string< OtherMaxLength > const &other) noexcept
Explicit conversion from another inline_string which cannot provably fit in this inline_string.
Definition inline_string.hpp:323
constexpr auto assign(std::initializer_list< detail::character > str) noexcept -> inline_string &
Assign from an initializer list of characters.
Definition inline_string.hpp:536
constexpr auto append(std::initializer_list< detail::character > rhs) noexcept -> inline_string &
Append a series of characters from an initializer list to the string.
Definition inline_string.hpp:1424
constexpr auto replace(const_iterator first, const_iterator last, string_view str, size_type pos) noexcept -> inline_string &
Replace a substring with another substring.
Definition inline_string.hpp:917
ARENE_NODISCARD constexpr auto compare(size_type pos, size_type length1, detail::raw_c_string other, size_type length2) const noexcept -> integral_comparison_result
Compare a substring against another string, to see if it is less than, equal to or greater than the o...
Definition inline_string.hpp:2014
constexpr inline_string(string_view const str) noexcept
Construct from the provided string_view.
Definition inline_string.hpp:273
constexpr auto operator=(detail::character chr) noexcept -> inline_string &
Assign from a single character.
Definition inline_string.hpp:475
constexpr auto assign(detail::raw_c_string str, size_type count) noexcept -> inline_string &
Assign from a string specified as pointer and length to the current string.
Definition inline_string.hpp:549
ARENE_NODISCARD constexpr auto rfind(detail::raw_c_string str, size_type pos, size_type count) const noexcept -> size_type
Find the latest position of the n character string starting at str within the string,...
Definition inline_string.hpp:1652
constexpr auto assign(size_type count, detail::character chr) noexcept -> inline_string &
Assign repeated copies of a single character.
Definition inline_string.hpp:567
ARENE_NODISCARD constexpr auto c_str() const noexcept -> detail::raw_c_string
Return a pointer to the NUL-terminated string held in *this.
Definition inline_string.hpp:1141
constexpr auto assign(string_view str) noexcept -> inline_string &
Assign from a string_view.
Definition inline_string.hpp:504
constexpr auto insert(const_iterator pos, detail::character chr) noexcept -> iterator
Insert the specified character starting at position pos.
Definition inline_string.hpp:658
constexpr auto replace(const_iterator first, const_iterator last, size_type count, detail::character chr) noexcept -> inline_string &
Replace a substring with repeated copies of a character.
Definition inline_string.hpp:982
ARENE_NODISCARD constexpr auto cbegin() const noexcept -> const_iterator
Definition inline_string.hpp:1264
constexpr auto replace(const_iterator first, const_iterator last, std::initializer_list< detail::character > chars) noexcept -> inline_string &
Replace a substring with a sequence of characters.
Definition inline_string.hpp:1005
constexpr auto erase(const_iterator first, const_iterator last) noexcept -> iterator
Erase the characters in the specified range.
Definition inline_string.hpp:771
ARENE_NODISCARD constexpr auto empty() const noexcept -> bool
Definition inline_string.hpp:1136
constexpr auto insert(const_iterator pos, std::initializer_list< detail::character > chars) noexcept -> iterator
Insert a series of characters into the string at the specified position.
Definition inline_string.hpp:686
ARENE_NODISCARD constexpr auto find_last_not_of(string_view str) const noexcept -> size_type
Find the latest position such that the character at that position is not one of those in the provided...
Definition inline_string.hpp:1862
ARENE_NODISCARD constexpr auto find(detail::raw_c_string str) const noexcept -> size_type
Find the earliest position of the given substring within the string.
Definition inline_string.hpp:1571
ARENE_NODISCARD constexpr auto find_last_of(detail::raw_c_string str, size_type pos, size_type count) const noexcept -> size_type
Find the latest position from the provided start position backwards such that the character at that p...
Definition inline_string.hpp:1836
ARENE_NODISCARD constexpr auto find_last_not_of(detail::raw_c_string str, size_type pos, size_type count) const noexcept -> size_type
Find the latest position from the provided start position backwards such that the character at that p...
Definition inline_string.hpp:1902
ARENE_NODISCARD constexpr auto compare(string_view other) const noexcept -> integral_comparison_result
Compare against another string, to see if it is less than, equal to or greater than the other.
Definition inline_string.hpp:1963
ARENE_NODISCARD constexpr auto find_first_of(detail::character chr, size_type pos) const noexcept -> size_type
Find the earliest position from the provided start position onwards such that the character at that p...
Definition inline_string.hpp:1717
static constexpr size_type npos
Definition inline_string.hpp:200
ARENE_NODISCARD constexpr auto find_first_not_of(detail::character chr) const noexcept -> size_type
Find the earliest position such that the character at that position is the provided character.
Definition inline_string.hpp:1776
constexpr auto replace(size_type pos, size_type count, string_view str) noexcept -> inline_string &
Replace a substring with another string.
Definition inline_string.hpp:791
constexpr auto operator=(inline_string const &) -> inline_string &=default
Default copy assignment.
ARENE_NODISCARD constexpr auto substr(size_type pos) const noexcept -> inline_string
Produce substring of the string starting at an offset.
Definition inline_string.hpp:1118
constexpr auto replace(const_iterator first, const_iterator last, string_view str, size_type pos, size_type count) noexcept -> inline_string &
Replace a substring with another substring.
Definition inline_string.hpp:940
ARENE_NODISCARD constexpr auto front() const noexcept -> detail::character const &
Get the first character in the string.
Definition inline_string.hpp:1212
ARENE_NODISCARD constexpr auto back() const noexcept -> detail::character const &
Get the last character in the string.
Definition inline_string.hpp:1230
ARENE_NODISCARD constexpr auto find_first_of(string_view str, size_type pos) const noexcept -> size_type
Find the earliest position from the provided start position onwards such that the character at that p...
Definition inline_string.hpp:1671
constexpr auto replace(const_iterator first, const_iterator last, InputIterator first2, InputIterator last2) noexcept(denotes_nothrow_iterable_range_v< InputIterator >) -> inline_string &
Replace a substring with another substring.
Definition inline_string.hpp:1031
constexpr auto copy(detail::character *str, size_type count, size_type pos) const -> size_type
Copy the substring starting at the specified position into the specified buffer up to the specified m...
Definition inline_string.hpp:1105
constexpr auto append(detail::character rhs) noexcept -> inline_string &
Append a character to the current string.
Definition inline_string.hpp:1415
constexpr auto erase(size_type pos) -> inline_string &
Erase characters from the string starting at the specified position to the end of the string.
Definition inline_string.hpp:723
constexpr auto replace(size_type pos, size_type count, string_view str, size_type pos2, size_type count2) noexcept -> inline_string &
Replace a substring with another substring.
Definition inline_string.hpp:832
ARENE_NODISCARD constexpr auto compare(size_type pos, size_type count, string_view other, size_type pos2) const noexcept -> integral_comparison_result
Compare a substring against a substring of another string, to see if it is less than,...
Definition inline_string.hpp:1986
ARENE_NODISCARD constexpr auto data() noexcept -> detail::character *
Return a pointer to the NUL-terminated string held in *this.
Definition inline_string.hpp:1151
constexpr auto replace(const_iterator first, const_iterator last, RandomAccessIterator first2, RandomAccessIterator last2) noexcept(denotes_nothrow_iterable_range_v< RandomAccessIterator >) -> inline_string &
Replace a substring with another substring.
Definition inline_string.hpp:1058
ARENE_NODISCARD constexpr auto find(detail::raw_c_string str, size_type pos) const noexcept -> size_type
Find the earliest position of the given substring within the string, starting at the specified positi...
Definition inline_string.hpp:1580
ARENE_NODISCARD constexpr auto end() noexcept -> iterator
Definition inline_string.hpp:1271
constexpr auto insert(size_type pos1, string_view str, size_type pos2, size_type length2) noexcept -> inline_string &
Insert the substring of the supplied string of max length length2 starting from pos2 at pos1.
Definition inline_string.hpp:613
static constexpr auto max_size() -> std::size_t
The maximum length of the string.
Definition inline_string.hpp:1162
ARENE_NODISCARD friend constexpr auto operator+(inline_string const &lhs, inline_string< OtherMaxLength > const &rhs) noexcept -> inline_string< MaxSize+OtherMaxLength >
Concatenate two strings.
Definition inline_string.hpp:2027
ARENE_NODISCARD constexpr auto find_last_not_of(detail::raw_c_string str) const noexcept -> size_type
Find the latest position such that the character at that position is not one of those in the provided...
Definition inline_string.hpp:1881
constexpr auto replace(size_type pos, size_type count, detail::raw_c_string str, size_type count2) noexcept -> inline_string &
Replace a substring with a c-string.
Definition inline_string.hpp:852
Trait to query if a type is an inline_string.
Definition inline_string.hpp:2319
A read-only string-view that provides a view onto a null-terminated string.
Definition null_terminated_string_view.hpp:62
Implementation of std::optional for pre-C++17 compilers, and which replaces defined undefined behavio...
Definition optional.hpp:122
Backport of the C++17 std::string_view class.
Definition string_view.hpp:54
constexpr auto copy(character *const dest, size_type const n) const noexcept -> size_type
Copy the first min(n,size()) characters to the destination buffer.
Definition string_view.hpp:395
constexpr auto find(string_view const str, size_type const pos=0U) const noexcept -> size_type
Find the earliest position of the given substring within the string, starting at the specified positi...
Definition string_view.hpp:511
constexpr auto rfind(string_view const str, size_type const pos=npos) const noexcept -> size_type
Find the latest position of the given substring within the string, starting at the specified position...
Definition string_view.hpp:568
static constexpr auto three_way_compare(string_view const lhs, string_view const rhs) noexcept -> strong_ordering
Compare two string_view objects lexicographically.
Definition string_view.hpp:874
constexpr auto find_last_not_of(string_view const str, size_type const pos=npos) const noexcept -> size_type
Finds the last character not equal to any of the characters in the given character sequence.
Definition string_view.hpp:807
static constexpr std::size_t npos
Special marker value for end of string.
Definition string_view.hpp:69
constexpr auto find_first_of(string_view const str, size_type const pos=0U) const noexcept -> size_type
Finds the first character equal to any of the characters in the given character sequence.
Definition string_view.hpp:635
constexpr auto find_first_not_of(string_view const str, size_type const pos=0U) const noexcept -> size_type
Finds the first character not equal to any of the characters in the given character sequence.
Definition string_view.hpp:691
constexpr auto starts_with(string_view const other) const noexcept -> bool
Check if the string starts with another string.
Definition string_view.hpp:459
constexpr auto find_last_of(string_view const str, size_type const pos=npos) const noexcept -> size_type
Finds the last character equal to one of characters in the given character sequence.
Definition string_view.hpp:747
constexpr auto compare(string_view const other) const noexcept -> integral_comparison_result
lexicographically compares two string_view, behavior similar to std::string
Definition string_view.hpp:252
constexpr auto substr() const noexcept -> string_view
Create a new string view referencing the same string as *this.
Definition string_view.hpp:334
constexpr auto ends_with(string_view const other) const noexcept -> bool
Check if the string ends with another string.
Definition string_view.hpp:486
Implementation of std::initializer_list for brace initialization.
Definition initializer_list.hpp:21
A helper class to represent a compile-time constant with the specified type and value....
Definition integral_constant.hpp:23
provides a uniform interface to the properties of an iterator
Definition iterator_traits.hpp:90
static constexpr auto max() noexcept -> T
The maximum finite value.
Definition numeric_limits.hpp:230
An empty tag type corresponding to a random access iterator.
Definition iterator_tags.hpp:29
#define ARENE_PRECONDITION(condition)
Check that a precondition holds, and terminate the application if it does not.
Definition contract.hpp:150
Provides implementation of constexpr backport of std::fill.
Definition accumulate.hpp:37
strong_ordering_detail::strong_ordering strong_ordering
The enumeration specifying the result of an ordering comparison.
Definition strong_ordering.hpp:147
is_inline_string< Type > is_inline_buffer_string
Trait to query if a type is an inline_string.
Definition inline_string.hpp:2334
constexpr auto distance(Iterator first, Iterator last) noexcept(noexcept(distance_impl::do_distance(first, last, typename std::iterator_traits< Iterator >::iterator_category{}))) -> typename std::iterator_traits< Iterator >::difference_type
Find the number of elements between first and last.
Definition distance.hpp:79
constexpr bool is_inline_string_v
Trait to query if a type is an inline_string.
constexpr auto copy(InputIterator first, InputIterator last, OutputIterator output) noexcept(noexcept(*(++output)) &&noexcept(*(++first)) &&noexcept(first !=last) &&std::is_nothrow_assignable<, typename std::iterator_traits< InputIterator >::reference >::value) -> OutputIterator
Copies the elements in the range, defined by [first, last), to another range beginning at output.
Definition copy.hpp:40
constexpr bool denotes_nothrow_iterable_range_v
Check if an iterator/sentinel pair form an iterable range that can be iterated without throwing.
constexpr void fill(Itr first, Sent last, T const &value) noexcept(std::is_nothrow_assignable<, T const & >::value &&denotes_nothrow_iterable_range_v< Itr, Sent >)
Assigns all elements in a sequence to a given value.
Definition fill.hpp:50
constexpr auto make_subrange(Iterator iterator, Sentinel sentinel) noexcept(std::is_nothrow_move_constructible< Iterator >::value &&//std::is_nothrow_move_constructible< Sentinel >::value) -> make_subrange_detail::iterator_range< Iterator, Sentinel >
Combine an iterator and sentinel into a range type that can be used with range-based for loops.
Definition make_subrange.hpp:98
typename constraints_impl::constraints< EnableIfs... >::type constraints
Helper used to express template constraints in a consistent way using std::enable_if_t.
Definition constraints.hpp:51
constexpr bool is_inline_buffer_string_v
Trait to query if a type is an inline_string.
inequality_heuristic
An enumeration used for the return value of fast_inequality_check functions to indicate if two values...
Definition operators.hpp:696
@ may_be_equal_or_not_equal
The values checked may or may not be equal to each other; a more detailed check is required.
Definition operators.hpp:700
@ definitely_not_equal
The two values checked are definitely not equal to each other.
Definition operators.hpp:698
Definition accumulate.hpp:36
::ptrdiff_t ptrdiff_t
A type suitable for holding the difference between two pointers.
Definition cstddef.hpp:31
::size_t size_t
A type suitable for holding the size of an object.
Definition cstddef.hpp:29
typename enable_if< Condition, Type >::type enable_if_t
Type alias to support constraining templates. Is an alias for the specified type if the Condition is ...
Definition enable_if.hpp:41
constexpr auto min(initializer_list< T > list, Compare comp) noexcept(noexcept(comp(std::declval< T & >(), std::declval< T & >())) &&std::is_nothrow_copy_constructible_v< T >) -> T
Returns the smallest value in the std::initializer_list.
Definition min_initializer_list_overload.hpp:50
static constexpr auto const & ignore
An object to which anything can be assigned, which ignores the assigned value.
Definition ignore.hpp:72
constexpr auto begin(Element(&array)[Size]) noexcept -> Element *
Obtain a pointer to the first element of the array.
Definition begin.hpp:28
constexpr auto cbegin(Container const &cont) noexcept(noexcept(::std::begin(std::declval< Container const & >()))) ->
Equivalent to invoking begin(cont) on a const container.
Definition begin.hpp:64
#define ARENE_NODISCARD
An alias for [[nodiscard]] , or a no-op if the attribute is not supported.
Definition nodiscard.hpp:26
Provides a backport of the constexpr implementation of std::reverse_iterator .
Provides backports of the safe integer comparison functions from C++20.