Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
inline_string.hpp
Go to the documentation of this file.
1// Copyright 2024, Toyota Motor Corporation
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
5#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_STRINGS_INLINE_STRING_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_STRINGS_INLINE_STRING_HPP_
7
8// IWYU pragma: private
9// IWYU pragma: friend "(arene/base(?!/tests)|stdlib/include/stdlib_detail)/.*"
10
11// parasoft-begin-suppress AUTOSAR-A16_2_2-a-2 "Arene Base aggregate headers permitted by A16-2-2 Permit #1"
12
22#include "arene/base/detail/exceptions.hpp"
23#include "arene/base/detail/raw_c_string.hpp"
24#include "arene/base/detail/wrapped_iterator.hpp" // IWYU pragma: keep
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" // IWYU pragma: keep
45// parasoft-end-suppress AUTOSAR-A16_2_2-a-2
46
47// parasoft-begin-suppress AUTOSAR-A7_1_5-a-2 "Trailing return syntax permitted by A7-1-5 Permit #1 v1.0.0"
48
49namespace arene {
50namespace base {
51
52namespace inline_string_detail {
53
54///
55/// @brief Base class for @c inline_string which detemplatizes functionality not dependent on the buffer size.
56///
57class inline_string_base {
58 public:
59 /// @brief The type used for @c size() and @c length()
60 using size_type = std::size_t;
61
62 protected:
63 /// @brief passkey class for constructing iterators.
64 class iterator_passkey {
65 public:
66 /// @brief The default constructor is explicit to disable construction with just @c {}
67 constexpr explicit iterator_passkey() noexcept = default;
68 };
69
70 // parasoft-begin-suppress CERT_C-EXP37-a-3 "False positive: The rule does not mention naming all parameters"
71 /// @brief Default constructor, protected to prevent slicing
72 constexpr inline_string_base() = default;
73 /// @brief Copy constructor, protected to prevent slicing
74 constexpr inline_string_base(inline_string_base const&) = default;
75 /// @brief Move constructor, protected to prevent slicing
76 constexpr inline_string_base(inline_string_base&&) = default;
77 /// @brief Copy assignment operator, protected to prevent slicing
78 constexpr auto operator=(inline_string_base const&) -> inline_string_base& = default;
79 /// @brief Move assignment operator, protected to prevent slicing
80 constexpr auto operator=(inline_string_base&&) -> inline_string_base& = default;
81 /// @brief Destructor, protected to prevent slicing
82 ~inline_string_base() = default;
83 // parasoft-end-suppress CERT_C-EXP37-a-3
84
85 public:
86 /// @brief The type of the elements contained in the string.
87 using value_type = detail::character;
88 /// @brief The type of a reference to an element in the string.
89 using reference = value_type&;
90 /// @brief The type of a const reference to an element in the string.
91 using const_reference = value_type const&;
92 /// @brief The type of a pointer to an element in the string.
93 using pointer = value_type*;
94 /// @brief The type of a const pointer to an element in the string
95 using const_pointer = value_type const*;
96 /// @brief The non-const iterator type
97 using iterator = ::arene::base::detail::wrapped_iterator<pointer, iterator_passkey>;
98 /// @brief The const iterator type
99 using const_iterator = ::arene::base::detail::wrapped_iterator<const_pointer, iterator_passkey>;
100 /// @brief The type of a non-const reverse iterator
101 using reverse_iterator = ::arene::base::reverse_iterator<iterator>;
102 /// @brief The type of a const reverse iterator
103 using const_reverse_iterator = ::arene::base::reverse_iterator<const_iterator>;
104 /// @brief The difference type between two iterators.
105 using difference_type = typename iterator::difference_type;
106
107 // parasoft-begin-suppress AUTOSAR-A2_10_1-d "False positive: 'size' does not hide anything"
108 /// @brief Get the length of the string
109 ///
110 /// @return The number of characters in the string, non-inclusive of the null-terminator. Equivalent to
111 /// @c distance(begin(),end())
112 constexpr auto size() const noexcept -> size_type { return string_length_; }
113 // parasoft-end-suppress AUTOSAR-A2_10_1-d
114
115 /// @brief Get the length of the string
116 ///
117 /// @return The same as @c size()
118 constexpr auto length() const noexcept -> size_type { return size(); }
119
120 // parasoft-begin-suppress AUTOSAR-A8_4_7-b-2 "Base class passed by reference to avoid slicing"
121 /// @brief Helper to detemplatize fast_inequality_check to remove uncovered branches for inline_string instantiations.
122 ///
123 /// @tparam SizeType The type used for the size comparison
124 /// @param lhs The left hand size
125 /// @param rhs The right hand size
126 /// @return inequality_heuristic::definitely_not_equal if lhs != rhs
127 /// @return inequality_heuristic::may_be_equal_or_not_equal if lhs == rhs
128 ///
129 static constexpr auto common_fast_inequality_check(inline_string_base const& lhs, string_view const& rhs) noexcept
131 return lhs.size() != rhs.size() ? inequality_heuristic::definitely_not_equal
133 }
134 // parasoft-end-suppress AUTOSAR-A8_4_7-b-2
135
136 protected:
137 /// @brief sets the size to a new value
138 ///
139 /// @param new_size the new size to set
140 /// @post @c size() will be @c new_size
141 constexpr void set_size(size_type const new_size) noexcept { string_length_ = new_size; }
142
143 private:
144 /// @brief The current size of the string
145 size_type string_length_{0U};
146};
147
148} // namespace inline_string_detail
149
150// parasoft-begin-suppress AUTOSAR-A10_1_1-a-2 "False positive: 'generic_ordering_from_three_way_compare' is an
151// interface"
152/// @brief A string type with a fixed maximum capacity, where the data is stored internally without allocations.
153///
154/// @tparam MaxSize the maximum capacity of the string, _not_ including the null terminator. Must be non-zero, and
155/// less than @c std::numeric_limits<difference_type>::max()
156template <std::size_t MaxSize>
157// NOLINTNEXTLINE(hicpp-special-member-functions) provides converting ctors that are equivalent to copy/move.
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>>
162 , generic_ordering_from_three_way_compare<inline_string<MaxSize>> {
163 /// @brief Internal type alias for the base class
165
166 // parasoft-begin-suppress AUTOSAR-A3_9_1-b-2 "Returning an int for compatibility with std::string_view"
167 /// @brief The type of comparisons that yield an integer rather than a @c strong_ordering
168 using integral_comparison_result = int;
169 // parasoft-end-suppress AUTOSAR-A3_9_1-b-2
170
171 public:
172 // parasoft-begin-suppress CERT_C-PRE31-c-3 "False positive: static_assert is a compile-time assert and can have no
173 // side-effects"
174 static_assert(
176 "Must have ability to get difference between iterators"
177 );
178 // parasoft-end-suppress CERT_C-PRE31-c-3
179
180 // member types
181 using typename inline_string_base::size_type;
182 using typename inline_string_base::value_type;
183
184 using typename inline_string_base::const_reference;
185 using typename inline_string_base::reference;
186
187 using typename inline_string_base::const_pointer;
188 using typename inline_string_base::pointer;
189
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;
194
195 using inline_string_std_string_mixin<inline_string>::three_way_compare;
196 using inline_string_std_string_mixin<inline_string>::fast_inequality_check;
197
198 // parasoft-begin-suppress AUTOSAR-M11_0_1-a-2 "False positive: this is not 'member data', it is a public property"
199 /// @brief Special marker for element not in string.
200 static constexpr size_type npos{string_view::npos};
201 // parasoft-end-suppress AUTOSAR-M11_0_1-a-2
202
203 /// @brief Use the default destructor
204 ~inline_string() = default;
205
206 /// @brief Default-construct an empty string
207 constexpr inline_string() noexcept = default;
208
209 // parasoft-begin-suppress AUTOSAR-A12_8_6-a "False positive: All base classes have protected copy constructor"
210 // parasoft-begin-suppress CERT_C-EXP37-a-3 "False positive: The rule does not mention naming all parameters"
211 /// @brief Default copy construction
212 constexpr inline_string(inline_string const&) = default;
213 // parasoft-end-suppress CERT_C-EXP37-a-3
214 // parasoft-end-suppress AUTOSAR-A12_8_6-a
215
216 // parasoft-begin-suppress CERT_C-EXP37-a-3 "False positive: The rule does not mention naming all parameters"
217 /// @brief Default move construction
218 constexpr inline_string(inline_string&&) = default;
219 // parasoft-end-suppress CERT_C-EXP37-a-3
220
221 // parasoft-begin-suppress AUTOSAR-A7_1_3-a "False positive: const is placed on the right hand side"
222 // parasoft-begin-suppress AUTOSAR-A12_1_1-a-2 "False positive: This constructor delegates to another, which does
223 // initialize the base class"
224 /// @brief Construct from the provided NUL-terminated string.
225 ///
226 /// @param str The source string
227 /// @pre The length of @c str must be less than @c MaxLength , else @c ARENE_PRECONDITION violation.
228 /// @pre @c str must point to a NUL-terminated string, else behavior is undefined.
229 /// @post @c size() is the length of @c str
230 /// @post The content of this string is equivalent to the content of @c str
231 constexpr explicit inline_string(detail::raw_c_string const str) noexcept
232 : inline_string{} {
233 copy_from(str);
234 }
235 // parasoft-end-suppress AUTOSAR-A12_1_1-a-2
236 // parasoft-end-suppress AUTOSAR-A7_1_3-a
237
238 // parasoft-begin-suppress AUTOSAR-A12_1_1-a-2 "False positive: This constructor delegates to another, which does
239 // initialize the base class"
240 /// @brief Construct from the source string literal
241 ///
242 /// @tparam N the size of the source character array. Must be @c <=(MaxLength+1)
243 /// @param str The string to copy from
244 /// @pre @c str must have a NUL terminator somewhere in it
245 /// @post The content of this string compares equal to @c str
246 template <std::size_t N>
247 // NOLINTNEXTLINE(hicpp-avoid-c-arrays, hicpp-explicit-conversions) string literal implementation can safely convert
248 constexpr inline_string(detail::character const (&str)[N]) noexcept
249 : inline_string{} {
250 static_assert(N - 1UL <= MaxSize, "String literal must fit into MaxLength");
251
252 // Like std::string, copy until the first NUL; if there's no NUL, it's not really a string => precondition violation
253 string_view as_view{&str[0], N};
254 auto const first_nul_idx = as_view.find('\0');
255 ARENE_PRECONDITION(first_nul_idx < as_view.size());
256 as_view = as_view.substr(0UL, first_nul_idx);
257
258 // We've just made sure that as_view.size() <= N - 1UL <= MaxSize, so we don't need the checked copy_from
259 copy_from_unchecked(as_view);
260 }
261 // parasoft-end-suppress AUTOSAR-A12_1_1-a-2
262
263 // parasoft-begin-suppress AUTOSAR-A7_1_3-a "False positive: const is placed on the right hand side"
264 // parasoft-begin-suppress AUTOSAR-A12_1_1-a-2 "False positive: This constructor delegates to another, which does
265 // initialize the base class"
266 /// @brief Construct from the provided string_view.
267 ///
268 /// @param str The source string
269 /// @pre The length of @c str must be less than @c MaxLength , else @c ARENE_PRECONDITION violation.
270 /// @pre @c str must point to a NUL-terminated string, else behavior is undefined.
271 /// @post @c size() is the length of @c str
272 /// @post The content of this string is equivalent to the content of @c str
273 constexpr explicit inline_string(string_view const str) noexcept
274 : inline_string{} {
275 copy_from(str);
276 }
277 // parasoft-end-suppress AUTOSAR-A12_1_1-a-2
278 // parasoft-end-suppress AUTOSAR-A7_1_3-a
279
280 // parasoft-begin-suppress AUTOSAR-A2_10_1-e "False positive: 'try_construct' does not hide anything"
281 // parasoft-begin-suppress AUTOSAR-A7_1_3-a "False positive: const is placed on the right hand side"
282 /// @brief Attempt to construct from a @c string_view .
283 ///
284 /// @param str The source string.
285 /// @return optional<inline_string> If @c str.size()>MaxLength , a null optional, else an optional populated as if
286 /// via @c inline_string{str} .
287 ///
288 static constexpr auto try_construct(string_view const str) noexcept -> optional<inline_string> {
289 if (str.length() > MaxSize) {
290 return nullopt;
291 }
292 return {inline_string{str}};
293 }
294 // parasoft-end-suppress AUTOSAR-A7_1_3-a
295 // parasoft-end-suppress AUTOSAR-A2_10_1-e
296
297 // parasoft-begin-suppress AUTOSAR-A12_1_1-a-2 "False positive: This constructor delegates to another, which does
298 // initialize the base class"
299 /// @brief Implicit conversion from another @c inline_string which can provably fit in this @c inline_string.
300 ///
301 /// @tparam OtherMaxLength The length of the other string. Must be @c <= MaxLength
302 /// @param other The other string
303 /// @post @c size()==other.size()
304 /// @post The content of this string is equivalent to the content of @c other
305 template <size_type OtherMaxLength, constraints<std::enable_if_t<(OtherMaxLength <= MaxSize)>> = nullptr>
306 // NOLINTNEXTLINE(hicpp-explicit-conversions) Morally this is a copy-ctor not a conversion
307 constexpr inline_string(inline_string<OtherMaxLength> const& other) noexcept
308 : inline_string{} {
309 copy_from(other);
310 }
311 // parasoft-end-suppress AUTOSAR-A12_1_1-a-2
312
313 // parasoft-begin-suppress AUTOSAR-A12_1_1-a-2 "False positive: This constructor delegates to another, which does
314 // initialize the base class"
315 /// @brief Explicit conversion from another @c inline_string which cannot provably fit in this @c inline_string.
316 ///
317 /// @tparam OtherMaxLength The length of the other string
318 /// @param other The other string
319 /// @pre @c other.size() is less than or equal to @c MaxLength else @c ARENE_PRECONDITION violation
320 /// @post @c size()==other.size()
321 /// @post The content of this string is equivalent to the content of @c other
322 template <size_type OtherMaxLength, constraints<std::enable_if_t<(OtherMaxLength > MaxSize)>> = nullptr>
323 constexpr explicit inline_string(inline_string<OtherMaxLength> const& other) noexcept
324 : inline_string{} {
325 copy_from(other);
326 }
327 // parasoft-end-suppress AUTOSAR-A12_1_1-a-2
328
329 // parasoft-begin-suppress AUTOSAR-A12_1_1-a "False positive: This constructor delegates to another, which does
330 // initialize the base class"
331
332 /// @brief Construct a pre-filled @c inline_string of a given length.
333 ///
334 /// @param len The length of the constructed string.
335 /// @param chr The character to fill the string.
336 /// @pre @c len must be less than or equal to @c MaxLength , else @c ARENE_PRECONDITION violation.
337 /// @post @c size() is equal to @c len .
338 /// @post This string is filled with @c chr .
339 constexpr inline_string(size_type len, detail::character chr) noexcept
340 : inline_string{} {
341 resize(len, chr);
342 }
343
344 // parasoft-end-suppress AUTOSAR-A12_1_1-a
345
346 // parasoft-begin-suppress AUTOSAR-A2_10_1-e "False positive: 'try_construct' does not hide anything"
347 /// @brief Attempt to construct from another @c inline_string with a capacity that is less than or equal to the
348 /// capacity of this.
349 ///
350 /// @tparam OtherMaxSize The capacity of the other string
351 /// @param str The source string.
352 /// @return If @c str.size()>MaxLength , a null optional, else an optional populated as if via @c inline_string{str} .
353 template <size_type OtherMaxSize, constraints<std::enable_if_t<(OtherMaxSize <= MaxSize)>> = nullptr>
354 static constexpr auto try_construct(inline_string<OtherMaxSize> const& str) noexcept -> optional<inline_string> {
355 return {inline_string{str}};
356 }
357 /// @brief Attempt to construct from another @c inline_string with a larger capacity.
358 ///
359 /// @tparam OtherMaxSize The capacity of the other string
360 /// @param str The source string.
361 /// @return If @c str.size()>MaxLength , a null optional, else an optional populated as if via @c inline_string{str} .
362 template <size_type OtherMaxSize, constraints<std::enable_if_t<(OtherMaxSize > MaxSize)>> = nullptr>
363 static constexpr auto try_construct(inline_string<OtherMaxSize> const& str) noexcept -> optional<inline_string> {
364 if (str.length() > MaxSize) {
365 return nullopt;
366 }
367 return {inline_string{str}};
368 }
369 // parasoft-end-suppress AUTOSAR-A2_10_1-e
370
371 // parasoft-begin-suppress AUTOSAR-A12_1_1-a-2 "False positive: This constructor delegates to another, which does
372 // initialize the base class"
373 /// @brief Construction from a sequence of characters represented as a pair of iterators.
374 ///
375 /// @tparam InputIterator The type of the iterators
376 /// @param first The start of the iterator range
377 /// @param last The end of the iterator range
378 /// @pre @c std::distance(first,last)<=MaxSize else @c ARENE_PRECONDITION violation.
379 template <typename InputIterator, constraints<std::enable_if_t<is_input_iterator_v<InputIterator>>> = nullptr>
380 constexpr explicit inline_string(
381 InputIterator const first,
382 InputIterator const last
384 : inline_string{} {
385 copy_from(typename std::iterator_traits<InputIterator>::iterator_category{}, first, last);
386 }
387 // parasoft-end-suppress AUTOSAR-A12_1_1-a-2
388
389 // parasoft-begin-suppress AUTOSAR-A2_10_1-e "False positive: 'try_construct' does not hide anything"
390 /// @brief Attempt to construct from a sequence of characters.
391 ///
392 /// @param first An iterator referring to the start of the source string
393 /// @param last An iterator referring to the end of the source string
394 /// @return optional<inline_string> If the length of the range is greater than @c MaxLength , a null optional, else an
395 /// optional populated with the elements in the range @c [first,last) .
396 ///
397 template <typename InputIterator, constraints<std::enable_if_t<is_input_iterator_v<InputIterator>>> = nullptr>
398 static constexpr auto
399 try_construct(InputIterator first, InputIterator last) noexcept(denotes_nothrow_iterable_range_v<InputIterator>)
401 return inline_string::do_try_construct(
403 first,
404 last
405 );
406 }
407 // parasoft-end-suppress AUTOSAR-A2_10_1-e
408
409 // parasoft-begin-suppress AUTOSAR-A12_8_6-a "False positive: All base classes have protected assignment"
410 // parasoft-begin-suppress CERT_C-EXP37-a-3 "False positive: The rule does not mention naming all parameters"
411 /// @brief Default copy assignment
412 /// @return A reference to @c *this
413 constexpr auto operator=(inline_string const&) -> inline_string& = default;
414 // parasoft-end-suppress CERT_C-EXP37-a-3
415 // parasoft-end-suppress AUTOSAR-A12_8_6-a
416
417 // parasoft-begin-suppress AUTOSAR-A12_8_6-a "False positive: All base classes have protected assignment"
418 // parasoft-begin-suppress CERT_C-EXP37-a-3 "False positive: The rule does not mention naming all parameters"
419 /// @brief Default move assignment
420 /// @return A reference to @c *this
421 constexpr auto operator=(inline_string&&) -> inline_string& = default;
422 // parasoft-end-suppress CERT_C-EXP37-a-3
423 // parasoft-end-suppress AUTOSAR-A12_8_6-a
424
425 // parasoft-begin-suppress AUTOSAR-A12_8_6-a "False positive: All base classes have protected assignment"
426 /// @brief Assign from a string_view.
427 ///
428 /// @param str The source string
429 /// @return inline_string& @c *this
430 /// @pre The length of @c str must be less than @c MaxLength , else @c ARENE_PRECONDITION violation.
431 /// @post @c size() is the length of @c str
432 /// @post The content of this string is equivalent to the content of @c str
433 constexpr auto operator=(string_view str) noexcept -> inline_string& {
434 copy_from(str);
435 return *this;
436 }
437 // parasoft-end-suppress AUTOSAR-A12_8_6-a
438
439 // parasoft-begin-suppress AUTOSAR-A12_8_6-a "False positive: All base classes have protected assignment"
440 /// @brief Assign from a nul-terminated string
441 ///
442 /// @param str The source string
443 /// @return inline_string& @c *this
444 /// @pre The length of @c str must be less than @c MaxLength , else @c ARENE_PRECONDITION violation.
445 /// @pre @c str must point to a NUL-terminated string, else behavior is undefined.
446 /// @post @c size() is the length of @c str
447 /// @post The content of this string is equivalent to the content of @c str
448 constexpr auto operator=(detail::raw_c_string str) noexcept -> inline_string& {
449 copy_from(str);
450 return *this;
451 }
452 // parasoft-end-suppress AUTOSAR-A12_8_6-a
453
454 // parasoft-begin-suppress AUTOSAR-A12_8_6-a "False positive: All base classes have protected assignment"
455 /// @brief Assign from an initializer list.
456 ///
457 /// @param str The source string
458 /// @return inline_string& @c *this
459 /// @pre The length of @c str must be less than @c MaxLength , else @c ARENE_PRECONDITION violation.
460 /// @post @c size() is the length of @c str
461 /// @post The content of this string is equivalent to the content of @c str
463 copy_from(string_view(str.begin(), str.size()));
464 return *this;
465 }
466 // parasoft-end-suppress AUTOSAR-A12_8_6-a
467
468 // parasoft-begin-suppress AUTOSAR-A12_8_6-a "False positive: All base classes have protected assignment"
469 /// @brief Assign from a single character
470 ///
471 /// @param chr The source character
472 /// @return inline_string& @c *this
473 /// @post @c size() is @c 1
474 /// @post The content of this string is @c chr
475 constexpr auto operator=(detail::character chr) noexcept -> inline_string& {
476 copy_from_unchecked(string_view(&chr, 1U));
477 return *this;
478 }
479 // parasoft-end-suppress AUTOSAR-A12_8_6-a
480
481 // parasoft-begin-suppress AUTOSAR-A12_8_6-a "False positive: All base classes have protected assignment"
482 /// @brief Assign from another string.
483 ///
484 /// @tparam OtherMaxLength the max length of the other string
485 /// @param other The source string
486 /// @return inline_string& @c *this
487 /// @pre @c other.size() is less than or equal to @c MaxLength else @c ARENE_PRECONDITION violation
488 /// @post @c size()==other.size()
489 /// @post The content of this string is equivalent to the content of @c other
490 template <std::size_t OtherMaxLength>
491 constexpr auto operator=(inline_string<OtherMaxLength> const& other) noexcept -> inline_string& {
492 copy_from(other);
493 return *this;
494 }
495 // parasoft-end-suppress AUTOSAR-A12_8_6-a
496
497 /// @brief Assign from a string_view.
498 ///
499 /// @param str The source string
500 /// @return inline_string& @c *this
501 /// @pre The length of @c str must be less than @c MaxLength , else @c ARENE_PRECONDITION violation.
502 /// @post @c size() is the length of @c str
503 /// @post The content of this string is equivalent to the content of @c str
504 constexpr auto assign(string_view str) noexcept -> inline_string& { return *this = str; }
505
506 /// @brief Assign from a string_view.
507 ///
508 /// @param str The source string
509 /// @param pos The offset in @c str of the substring to assign
510 /// @return inline_string& @c *this
511 /// @pre @c str.substr(pos).size() must be less than @c MaxLength , else @c ARENE_PRECONDITION violation.
512 /// @post @c size() is @c str.substr(pos).size()
513 /// @post The content of this string is equivalent to the content of @c str.substr(pos)
514 constexpr auto assign(string_view str, size_type pos) noexcept -> inline_string& { return assign(str.substr(pos)); }
515
516 /// @brief Assign from a substring of a string_view starting at the specified position, with the specified max length.
517 ///
518 /// @param str The source string
519 /// @param pos The offset in @c str of the substring to assign
520 /// @param count The maximum number of characters in the substring
521 /// @return inline_string& @c *this
522 /// @pre @c str.substr(pos,count).size() must be less than @c MaxLength , else @c ARENE_PRECONDITION violation.
523 /// @post @c size() is @c str.substr(pos).size()
524 /// @post The content of this string is equivalent to the content of @c str.substr(pos,count)
525 constexpr auto assign(string_view str, size_type pos, size_type count) noexcept -> inline_string& {
526 return assign(str.substr(pos, count));
527 }
528
529 /// @brief Assign from an initializer list of characters.
530 ///
531 /// @param str The source initializer list
532 /// @return inline_string& @c *this
533 /// @pre The length of @c str must be less than @c MaxLength , else @c ARENE_PRECONDITION violation.
534 /// @post @c size() is the length of @c str
535 /// @post The content of this string is equivalent to the content of @c str
536 constexpr auto assign(std::initializer_list<detail::character> str) noexcept -> inline_string& { return *this = str; }
537
538 /// @brief Assign from a string specified as pointer and length to the current string.
539 ///
540 /// @param str The start if the string to assign
541 /// @param count The number of characters in the string to assign
542 /// @return inline_string& @c *this
543 /// @pre str must not be @c nullptr , else @c ARENE_PRECONDITION violation.
544 /// @pre str must be a null-terminated string, else behavior is undefined.
545 /// @pre count must be less than the length of @c str, else behavior is undefined.
546 /// @pre The length of @c str must be less than @c MaxLength , else @c ARENE_PRECONDITION violation.
547 /// @post @c size() is the length of @c str
548 /// @post The content of this string is equivalent to the content of @c str
549 constexpr auto assign(detail::raw_c_string str, size_type count) noexcept -> inline_string& {
550 return assign(string_view{str, count});
551 }
552
553 /// @brief Assign from a single character
554 ///
555 /// @param chr The source character
556 /// @return inline_string& @c *this
557 /// @post @c size() is @c 1
558 /// @post The content of this string is @c chr
559 constexpr auto assign(detail::character chr) noexcept -> inline_string& { return *this = chr; }
560
561 /// @brief Assign repeated copies of a single character
562 ///
563 /// @param count The number of times to repeat the character
564 /// @param chr The source character
565 /// @return inline_string& @c *this
566 /// @pre @c count<=MaxLength , else @c ARENE_PRECONDITION violation.
567 constexpr auto assign(size_type count, detail::character chr) noexcept -> inline_string& {
568 ARENE_PRECONDITION(count <= MaxSize);
569 clear();
570 resize(count, chr);
571 return *this;
572 }
573
574 /// @brief Insert the supplied string at the specified position.
575 ///
576 /// @param pos The insertion position
577 /// @param str The string to insert
578 /// @return inline_string& @c *this
579 /// @pre @c pos<=size() else @c ARENE_PRECONDITION violation.
580 /// @pre @c pos+str.length()<max_size() , else @c ARENE_PRECONDITION violation.
581 /// @post @c size() is increased by @c str.size() .
582 /// @post @c str is inserted at @c pos
583 constexpr auto insert(size_type pos, string_view str) noexcept -> inline_string& {
584 std::ignore = ::arene::base::copy(str.begin(), str.end(), prepare_insert(pos, str.size()));
585 return *this;
586 }
587
588 /// @brief Insert the substring of the supplied string starting from @c pos2 at @c pos1.
589 ///
590 /// @param pos1 The insertion position
591 /// @param str The string holding the substring to insert
592 /// @param pos2 The position of the start of the substring to insert. If @c >=str.size(), this is a no-op.
593 /// @return inline_string& @c *this
594 /// @pre @c pos1<=size() else @c ARENE_PRECONDITION violation.
595 /// @pre @c pos1+(str.length()-pos2)<max_size() , else @c ARENE_PRECONDITION violation.
596 /// @post @c size() is increased by @c (str.size()-pos2) .
597 /// @post The range @c [str.begin()+pos2,str.end()) is inserted at @c pos1
598 constexpr auto insert(size_type pos1, string_view str, size_type pos2) noexcept -> inline_string& {
599 return insert(pos1, str.substr(pos2));
600 }
601
602 /// @brief Insert the substring of the supplied string of max length @c length2 starting from @c pos2 at @c pos1.
603 ///
604 /// @param pos1 The insertion position
605 /// @param str The string holding the substring to insert
606 /// @param pos2 The position of the start of the substring to insert. If @c >=str.size(), this is a no-op.
607 /// @param length2 The maximum length of the substring to insert
608 /// @return inline_string& @c *this
609 /// @pre @c pos1<=size() else @c ARENE_PRECONDITION violation.
610 /// @pre @c pos1+min(length2,str.size()-pos2)<max_size() , else @c ARENE_PRECONDITION violation.
611 /// @post @c size() is increased by @c min(length2,str.size()-pos2) .
612 /// @post The range @c [str.begin()+pos2,str.begin()+min(length2,str.size()-pos2)) is inserted at @c pos1
613 constexpr auto insert(size_type pos1, string_view str, size_type pos2, size_type length2) noexcept -> inline_string& {
614 return insert(pos1, str.substr(pos2, length2));
615 }
616
617 /// @brief Insert the string of @c count characters starting at @c str at @c pos
618 ///
619 /// @param pos The insertion position
620 /// @param str The start of the string to insert
621 /// @param count The length of the string to insert
622 /// @return inline_string& @c *this
623 /// @pre @c pos<=size() else @c ARENE_PRECONDITION violation.
624 /// @pre @c pos+count<max_size() , else @c ARENE_PRECONDITION violation.
625 /// @pre @c str+count must be in the valid range of @c str else behavior is undefined.
626 /// @post @c size() is increased by @c count .
627 /// @post @c str is inserted at @c pos
628 constexpr auto insert(size_type pos, detail::raw_c_string str, size_type count) noexcept -> inline_string& {
629 return insert(pos, string_view{str, count});
630 }
631
632 /// @brief Insert @c count copies of the specified character starting at position @c pos
633 ///
634 /// @param pos The insertion position
635 /// @param count The number of times to insert the character
636 /// @param chr The character to insert
637 /// @return inline_string& @c *this
638 /// @pre @c pos<=size() else @c ARENE_PRECONDITION violation.
639 /// @pre @c pos+count<max_size() , else @c ARENE_PRECONDITION violation.
640 /// @post @c size() is increased by @c count .
641 /// @post @c count copies of @c chr are inserted beginning at @c pos
642 // NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
643 constexpr auto insert(size_type pos, size_type count, detail::character chr) 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);
646 return *this;
647 }
648
649 /// @brief Insert the specified character starting at position @c pos
650 ///
651 /// @param pos The insertion position
652 /// @param chr The character to insert
653 /// @return iterator An iterator referring to the inserted character
654 /// @pre @c pos must be a valid iterator into @c *this else behavior is undefined.
655 /// @pre @c size()+1<max_size() , else @c ARENE_PRECONDITION violation.
656 /// @post @c size() is increased by @c 1 .
657 /// @post @c chr is inserted at @c pos
658 constexpr auto insert(const_iterator pos, detail::character chr) noexcept -> iterator { return insert(pos, 1U, chr); }
659
660 /// @brief Insert @c count copies of a character into the string at the specified position.
661 ///
662 /// @param pos An iterator representing the position to insert
663 /// @param count The number of times to insert the character
664 /// @param chr The character to insert
665 /// @return iterator An iterator referring to the start of the sequence of inserted characters.
666 /// @pre @c pos must be a valid iterator into @c *this else behavior is undefined.
667 /// @pre @c pos+count<max_size() , else @c ARENE_PRECONDITION violation.
668 /// @post @c size() is increased by @c count .
669 /// @post @c count copies of @c chr are inserted beginning at @c pos
670 // NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
671 constexpr auto insert(const_iterator pos, size_type count, detail::character chr) noexcept -> iterator {
672 auto const offset = pos - cbegin();
673 std::ignore = insert(static_cast<size_type>(offset), count, chr);
674 return begin() + offset;
675 }
676
677 /// @brief Insert a series of characters into the string at the specified position.
678 ///
679 /// @param pos An iterator representing the position to insert
680 /// @param chars The characters to insert
681 /// @return iterator An iterator referring to the start of the sequence of inserted characters.
682 /// @pre @c pos must be a valid iterator into @c *this else behavior is undefined.
683 /// @pre @c pos+chars.size()<max_size() , else @c ARENE_PRECONDITION violation.
684 /// @post @c size() is increased by @c chars.size() .
685 /// @post @c chars are inserted beginning at @c pos
686 constexpr auto insert(const_iterator pos, std::initializer_list<detail::character> chars) noexcept -> iterator {
687 auto const offset = pos - cbegin();
688 std::ignore = insert(static_cast<size_type>(offset), string_view{chars.begin(), chars.size()});
689 return begin() + offset;
690 }
691
692 /// @brief Insert a series of characters from an iterator range into the string at the specified position.
693 ///
694 /// @tparam InputIterator The type of the input iterator.
695 /// @param pos An iterator representing the position to insert
696 /// @param first The start of the input range
697 /// @param last The end of the input range
698 /// @return iterator An iterator referring to the start of the sequence of inserted characters.
699 /// @pre @c size()+std::distance(first,last)<=max_size() else @c ARENE_PRECONDITION violation.
700 /// @pre @c pos must be a valid iterator into @c *this
701 /// @pre @c InputIterator must be an input iterator
702 /// @pre @c first and @c last must form a valid iterator range
703 template <typename InputIterator, constraints<std::enable_if_t<base::is_input_iterator_v<InputIterator>>> = nullptr>
704 constexpr auto insert(
705 const_iterator pos,
706 InputIterator first,
707 InputIterator last
709 return do_insert(typename std::iterator_traits<InputIterator>::iterator_category{}, pos, first, last);
710 }
711
712 /// @brief Erase all the characters in the string.
713 /// @return inline_string& @c *this
714 constexpr auto erase() noexcept -> inline_string& {
715 clear();
716 return *this;
717 }
718
719 /// @brief Erase characters from the string starting at the specified position to the end of the string
720 /// @param pos The position of the first character to remove. If @c >=size() is a noop.
721 /// @return inline_string& @c *this
722 /// @post If @c pos<size() , @c size() is reduced by the difference between the original @c size() and @c pos .
723 constexpr auto erase(size_type pos) -> inline_string& {
724 // This can wrap around if pos > size(), but in that case the body of 2-arg erase will be skipped.
725 return erase(pos, this->size() - pos);
726 }
727
728 /// @brief Erase the specified number of characters in the string starting at the specified position.
729 ///
730 /// @param pos The position of the characters to remove. If @c pos>=size() this is a noop.
731 /// @param count The maximum number of characters to remove.
732 /// @return inline_string& @c *this
733 /// @post If @c pos<size() , then @c size() is reduced by @c min(count,size()-pos) .
734 /// @post If @c pos<size() , then the characters in the range @c [pos,min(size(),count+size())) are removed, and the
735 /// characters in the range [min(size(),count+size()),size()) are moved to be located starting at @c pos .
736 constexpr auto erase(size_type pos, size_type count) noexcept -> inline_string& {
737 if (pos < this->size()) {
738 count = std::min(count, this->size() - pos);
739 // From here, pos < size(), count <= size(), and pos + count <= size()
740 size_type const erase_end{pos + count};
742 begin() + static_cast<difference_type>(erase_end),
743 end(),
744 begin() + static_cast<difference_type>(pos)
745 );
746 set_null_terminator_to(this->size() - count);
747 }
748
749 return *this;
750 }
751
752 /// @brief Erase the character at the specified range.
753 /// @pre @c pos must be a valid iterator into the current string
754 /// @param pos The iterator referring to the character to erase
755 /// @return An iterator referring to the character after the removed range,
756 /// or @c end() if there is no such character
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()));
760 std::ignore = erase(static_cast<size_type>(offset), 1U);
761 return begin() + offset;
762 }
763
764 /// @brief Erase the characters in the specified range.
765 /// @pre @c first and @c last must form a valid iterator range into the
766 /// current string
767 /// @param first The start of the range
768 /// @param last The end of the range
769 /// @return An iterator referring to the character after the removed range,
770 /// or @c end() if there is no such character
771 constexpr auto erase(const_iterator first, const_iterator last) noexcept -> iterator {
772 ARENE_PRECONDITION(last >= first);
773 auto const offset = first - cbegin();
774 ARENE_PRECONDITION(offset >= 0);
775 std::ignore = erase(static_cast<size_type>(offset), static_cast<size_type>(last - first));
776 return begin() + offset;
777 }
778
779 /// @brief Replace a substring with another string.
780 ///
781 /// @param pos The start of the substring to replace.
782 /// @param count The length of the substring to replace
783 /// @param str The string to replace the substring with
784 /// @return inline_string& @c *this
785 /// @post The characters in the range @c [pos,std::min(pos+count,size())) are replaced by the characters in @c str .
786 /// @post If @c count<str.size() , then the remaining characters from @c str are inserted at the position equivalent
787 /// to @c pos+count .
788 /// @post If @c count<str.size(), then @c size() will increase by the difference.
789 /// @pre @c pos<=size() else @c ARENE_PRECONDITION violation.
790 /// @pre If @c count<str.size(), then @c size()+(str.size()-count)<=max_size() else @c ARENE_PRECONDITION violation.
791 constexpr auto replace(size_type pos, size_type count, string_view str) noexcept -> inline_string& {
792 prepare_replace(pos, count, str.length());
793 std::ignore = ::arene::base::copy(str.begin(), str.end(), begin() + static_cast<difference_type>(pos));
794 return *this;
795 }
796
797 /// @brief Replace a substring with another substring.
798 ///
799 /// @param pos The start of the substring to replace.
800 /// @param count The length of the substring to replace
801 /// @param str The string to replace the substring with
802 /// @param pos2 The offset into @c str to start the replacement string. If @c pos2>str.size() , this is a no-op.
803 /// @return inline_string& @c *this
804 /// @post The characters in the range @c [pos,std::min(pos+count,size())) are replaced by the characters in the range
805 /// @c [pos2,str.size()) .
806 /// @post If @c count<(str.size()-pos2) , then the remaining characters from @c str are inserted at the position
807 /// equivalent to @c pos+count .
808 /// @post If @c count<(str.size()-pos2) , then @c size() will increase by the difference.
809 /// @pre @c pos<=size() else @c ARENE_PRECONDITION violation.
810 /// @pre If @c count<(str.size()-pos2), then @c size()+(str.size()-pos2-count)<=max_size() else @c ARENE_PRECONDITION
811 /// violation.
812 constexpr auto replace(size_type pos, size_type count, string_view str, size_type pos2) noexcept -> inline_string& {
813 return replace(pos, count, str.substr(pos2));
814 }
815
816 /// @brief Replace a substring with another substring.
817 ///
818 /// @param pos The start of the substring to replace.
819 /// @param count The length of the substring to replace
820 /// @param str The string to replace the substring with
821 /// @param pos2 The offset into @c str to start the replacement string. If @c pos2>str.size() , this is a no-op.
822 /// @param count2 The count into @c str to cap the replacement.
823 /// @return inline_string& @c *this
824 /// @post The characters in the range @c [pos,std::min(pos+count,size())) are replaced by the characters in the range
825 /// @c [pos2,std::min(count2,str.size())) .
826 /// @post If @c count<(std::min(count2,str.size())-pos2) , then the remaining characters from @c str are inserted at
827 /// the position equivalent to @c pos+count .
828 /// @post If @c count<(std::min(count2,str.size())-pos2) , then @c size() will increase by the difference.
829 /// @pre @c pos<=size() else @c ARENE_PRECONDITION violation.
830 /// @pre If @c count<(std::min(count2,str.size())-pos2), then @c size()+(str.size()-pos2-count)<=max_size() else
831 /// @c ARENE_PRECONDITION violation.
832 constexpr auto replace(size_type pos, size_type count, string_view str, size_type pos2, size_type count2) noexcept
833 -> inline_string& {
834 return replace(pos, count, str.substr(pos2, count2));
835 }
836
837 /// @brief Replace a substring with a c-string.
838 ///
839 /// @param pos The start of the substring to replace.
840 /// @param count The length of the substring to replace
841 /// @param str The string to replace the substring with
842 /// @param count2 The count into @c str to cap the replacement.
843 /// @return inline_string& @c *this
844 /// @post The characters in the range @c [pos,std::min(pos+count,size())) are replaced by the characters in the range
845 /// @c [str,str+count) .
846 /// @post If @c count<count2 , then the remaining characters from @c str are inserted at
847 /// the position equivalent to @c pos+count .
848 /// @post If @c count<count2 , then @c size() will increase by the difference.
849 /// @pre @c pos<=size() else @c ARENE_PRECONDITION violation.
850 /// @pre @c str+count must be in the valid range of @c str else behavior is undefined.
851 /// @pre If @c count<count2, then @c size()+(count2-count)<=max_size() else @c ARENE_PRECONDITION violation.
852 constexpr auto replace(size_type pos, size_type count, detail::raw_c_string str, size_type count2) noexcept
853 -> inline_string& {
854 return replace(pos, count, string_view{str, count2});
855 }
856
857 /// @brief Replace a substring with repeated copies of a given character.
858 ///
859 /// @param pos The start of the substring to replace.
860 /// @param count The length of the substring to replace
861 /// @param count2 The number of characters to fill.
862 /// @param chr The character to fill with.
863 /// @return inline_string& @c *this
864 /// @post The characters in the range @c [pos,std::min(pos+count,size())) are replaced by @c count2 copies of chr
865 /// @post If @c count<count2 , then the remaining copies of @c chr are inserted at the position equivalent
866 /// to @c pos+count , and @c size() will increase by the difference
867 /// @post If @c count>count2 , then the remaining characters in the replacement range will be erased, and @c size()
868 /// will decrease by the difference.
869 /// @pre @c pos<=size() else @c ARENE_PRECONDITION violation.
870 /// @pre If @c count<count2, then @c size()+(count2-count)<=max_size() else @c ARENE_PRECONDITION violation.
871 // NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
872 constexpr auto replace(size_type pos, size_type count, size_type count2, detail::character chr) noexcept
873 -> inline_string& {
874 prepare_replace(pos, count, count2);
875 auto const fill_begin = begin() + static_cast<difference_type>(pos);
876 ::arene::base::fill(fill_begin, fill_begin + static_cast<difference_type>(count2), chr);
877 return *this;
878 }
879
880 /// @brief Replace a substring with another string.
881 ///
882 /// @param first The start of the substring to replace.
883 /// @param last The end of the substring to replace
884 /// @param str The string to replace the substring with
885 /// @return inline_string& @c *this
886 /// @post The characters in the range @c [first,last) are replaced by the characters in @c str .
887 /// @post If @c std::distance(first,last)<str.size() , then the remaining characters from @c str are inserted
888 /// at @c last , and @c size() will increase by the difference.
889 /// @post If @c std::distance(first,last)>str.size(), then the remain characters from @c [first,last) are erased and
890 /// @c size() will decrease by the difference.
891 /// @pre @c pos<=size() else @c ARENE_PRECONDITION violation.
892 /// @pre Let @c dist=std::distance(first,last) ; if @c dist<str.size(), then
893 /// @c size()+(str.size()-dist)<=max_size() else @c ARENE_PRECONDITION violation.
894 constexpr auto replace(const_iterator first, const_iterator last, string_view str) noexcept -> inline_string& {
895 ARENE_PRECONDITION(last >= first);
896 auto const offset = first - cbegin();
897 ARENE_PRECONDITION(offset >= 0);
898 return replace(static_cast<size_type>(offset), static_cast<size_type>(last - first), str);
899 }
900
901 /// @brief Replace a substring with another substring.
902 ///
903 /// @param first The start of the substring to replace.
904 /// @param last The end of the substring to replace
905 /// @param str The string to replace the substring with
906 /// @param pos The offset into @c str to start the replacement string. If @c pos>str.size() , this is a no-op.
907 /// @return inline_string& @c *this
908 /// @post The characters in the range @c [first,last) are replaced by the characters in the
909 /// range @c [str.begin()+pos,str.end()) .
910 /// @post If @c std::distance(first,last)<(str.size()-pos) , then the remaining characters from @c str are inserted
911 /// at @c last , and @c size() will increase by the difference.
912 /// @post If @c std::distance(first,last)>(str.size()-pos), then the remain characters from @c [first,last) are erased
913 /// and @c size() will decrease by the difference.
914 /// @pre @c pos<=size() else @c ARENE_PRECONDITION violation.
915 /// @pre Let @c dist=std::distance(first,last) ; if @c dist<(str.size()-pos), then
916 /// @c size()+(str.size()-pos-dist)<=max_size() else @c ARENE_PRECONDITION violation.
917 constexpr auto replace(const_iterator first, const_iterator last, string_view str, size_type pos) noexcept
918 -> inline_string& {
919 return replace(first, last, str.substr(pos));
920 }
921
922 /// @brief Replace a substring with another substring.
923 ///
924 /// @param first The start of the substring to replace.
925 /// @param last The end of the substring to replace
926 /// @param str The string to replace the substring with
927 /// @param pos The offset into @c str to start the replacement string. If @c pos>str.size() , this is a no-op.
928 /// @param count The count into @c str to cap the replacement.
929 /// @return inline_string& @c *this
930 /// @post The characters in the range @c [first,last) are replaced by the characters in the
931 /// range @c [str.begin()+pos,str.begin()+std::min(str.size(),count)) .
932 /// @post If @c std::distance(first,last)<std::min(str.size()-pos,count) , then the remaining characters from @c str
933 /// are inserted at @c last , and @c size() will increase by the difference.
934 /// @post If @c std::distance(first,last)>std::min(str.size()-pos,count), then the remain characters from
935 /// @c [first,last) are erased and @c size() will decrease by the difference.
936 /// @pre @c pos<=size() else @c ARENE_PRECONDITION violation.
937 /// @pre Let @c dist=std::distance(first,last) and @c length=std::min(str.size()-pos,count) ;
938 /// if @c dist<length, then @c size()+(length-dist)<=max_size() else @c ARENE_PRECONDITION violation.
939 constexpr auto
940 replace(const_iterator first, const_iterator last, string_view str, size_type pos, size_type count) noexcept
941 -> inline_string& {
942 return replace(first, last, str.substr(pos, count));
943 }
944
945 /// @brief Replace a substring with a c-string.
946 ///
947 /// @param first The start of the substring to replace.
948 /// @param last The end of the substring to replace
949 /// @param str The string to replace the substring with
950 /// @param count The count into @c str to cap the replacement.
951 /// @return inline_string& @c *this
952 /// @post The characters in the range @c [first,last) are replaced by the characters in the
953 /// range @c [str+pos,str+count) .
954 /// @post If @c std::distance(first,last)<count , then the remaining characters from @c str
955 /// are inserted at @c last , and @c size() will increase by the difference.
956 /// @post If @c std::distance(first,last)>count, then the remain characters from
957 /// @c [first,last) are erased and @c size() will decrease by the difference.
958 /// @pre @c pos<=size() else @c ARENE_PRECONDITION violation.
959 /// @pre @c str+count must be in the valid range of @c str else behavior is undefined.
960 /// @pre Let @c dist=std::distance(first,last) ; if @c dist<count, then @c size()+(count-dist)<=max_size() else
961 /// @c ARENE_PRECONDITION violation.
962 constexpr auto replace(const_iterator first, const_iterator last, detail::raw_c_string str, size_type count) noexcept
963 -> inline_string& {
964 return replace(first, last, string_view{str, count});
965 }
966
967 /// @brief Replace a substring with repeated copies of a character.
968 ///
969 /// @param first The start of the substring to replace.
970 /// @param last The end of the substring to replace
971 /// @param count The count into @c str to cap the replacement.
972 /// @param chr The character to fill with.
973 /// @return inline_string& @c *this
974 /// @post The characters in the range @c [first,last) are replaced by @c count repeated copies of @c chr
975 /// @post If @c std::distance(first,last)<count , then the remaining characters are inserted at @c last , and
976 /// @c size() will increase by the difference.
977 /// @post If @c std::distance(first,last)>count, then the remain characters from @c [first,last) are erased and
978 /// @c size() will decrease by the difference.
979 /// @pre @c pos<=size() else @c ARENE_PRECONDITION violation.
980 /// @pre Let @c dist=std::distance(first,last) ; if @c dist<count, then @c size()+(count-dist)<=max_size() else
981 /// @c ARENE_PRECONDITION violation.
982 constexpr auto replace(const_iterator first, const_iterator last, size_type count, detail::character chr) noexcept
983 -> inline_string& {
984 ARENE_PRECONDITION(last >= first);
985 auto const offset = first - cbegin();
986 ARENE_PRECONDITION(offset >= 0);
987 return replace(static_cast<size_type>(offset), static_cast<size_type>(last - first), count, chr);
988 }
989
990 /// @brief Replace a substring with a sequence of characters.
991 ///
992 /// @param first The start of the substring to replace.
993 /// @param last The end of the substring to replace
994 /// @param chars the sequence of characters to replace
995 /// @return inline_string& @c *this
996 /// @post The characters in the range @c [first,last) are replaced by the characters from @c chars
997 /// @post If @c std::distance(first,last)<chars.size() , then the remaining characters from @c chars
998 /// are inserted at @c last , and @c size() will increase by the difference.
999 /// @post If @c std::distance(first,last)>chars.size(), then the remain characters from
1000 /// @c [first,last) are erased and @c size() will decrease by the difference.
1001 /// @pre @c pos<=size() else @c ARENE_PRECONDITION violation.
1002 /// @pre Let @c dist=std::distance(first,last) ; if @c dist<chars.size(), then @c size()+(str.size()-dist)<=max_size()
1003 /// else @c ARENE_PRECONDITION violation.
1004 constexpr auto
1005 replace(const_iterator first, const_iterator last, std::initializer_list<detail::character> chars) noexcept
1006 -> inline_string& {
1007 return replace(first, last, string_view{chars.begin(), chars.size()});
1008 }
1009
1010 /// @brief Replace a substring with another substring.
1011 ///
1012 /// @tparam InputIterator The iterator type
1013 /// @param first The start of the substring to replace.
1014 /// @param last The end of the substring to replace
1015 /// @param first2 The start of the substring to replace the substring with
1016 /// @param last2 The end of the substring to replace the substring with.
1017 /// @return inline_string& @c *this
1018 /// @post The characters in the range @c [first,last) are replaced by the characters in the range @c [first2,last2) .
1019 /// @post If @c std::distance(first,last)<std::distance(first2,last2) , then the remaining characters from
1020 /// @c [first2,last2] are inserted at @c last , and @c size() will increase by the difference.
1021 /// @post If @c std::distance(first,last)>std::distance(first2,last2), then the remain characters from
1022 /// @c [first,last) are erased and @c size() will decrease by the difference.
1023 /// @pre @c pos<=size() else @c ARENE_PRECONDITION violation.
1024 /// @pre Let @c dist=std::distance(first,last) and @c length=std::distance(first,last) ;
1025 /// if @c dist<length, then @c size()+(length-dist)<=max_size() else @c ARENE_PRECONDITION violation.
1026 template <
1027 typename InputIterator,
1031 constexpr auto replace(
1032 const_iterator first,
1033 const_iterator last,
1034 InputIterator first2,
1035 InputIterator last2
1037 return replace(first, last, inline_string{first2, last2});
1038 }
1039 /// @brief Replace a substring with another substring.
1040 ///
1041 /// @tparam RandomAccessIterator The iterator type
1042 /// @param first The start of the substring to replace.
1043 /// @param last The end of the substring to replace
1044 /// @param first2 The start of the substring to replace the substring with
1045 /// @param last2 The end of the substring to replace the substring with.
1046 /// @return inline_string& @c *this
1047 /// @post The characters in the range @c [first,last) are replaced by the characters in the range @c [first2,last2) .
1048 /// @post If @c std::distance(first,last)<std::distance(first2,last2) , then the remaining characters from
1049 /// @c [first2,last2] are inserted at @c last , and @c size() will increase by the difference.
1050 /// @post If @c std::distance(first,last)>std::distance(first2,last2), then the remain characters from
1051 /// @c [first,last) are erased and @c size() will decrease by the difference.
1052 /// @pre @c pos<=size() else @c ARENE_PRECONDITION violation.
1053 /// @pre Let @c dist=std::distance(first,last) and @c length=std::distance(first,last) ;
1054 /// if @c dist<length, then @c size()+(length-dist)<=max_size() else @c ARENE_PRECONDITION violation.
1055 template <
1056 typename RandomAccessIterator,
1058 constexpr auto replace(
1059 const_iterator first,
1060 const_iterator last,
1061 RandomAccessIterator first2,
1062 RandomAccessIterator last2
1064 auto const length_of_replacement = last2 - first2;
1065 ARENE_PRECONDITION(length_of_replacement >= 0);
1066 ARENE_PRECONDITION(last >= first);
1067 auto const offset = first - cbegin();
1068 ARENE_PRECONDITION(offset >= 0);
1069 inline_string::size_type pos{static_cast<inline_string::size_type>(offset)};
1070 prepare_replace(
1071 pos,
1072 static_cast<inline_string::size_type>(last - first),
1073 static_cast<inline_string::size_type>(length_of_replacement)
1074 );
1075 std::ignore = ::arene::base::copy(first2, last2, begin() + offset);
1076 return *this;
1077 }
1078
1079 /// @brief Remove the last character.
1080 /// @post @c size() is reduced by 1.
1081 /// @pre The string must not be empty, else @c ARENE_PRECONDITION violation.
1082 constexpr void pop_back() noexcept {
1084 std::ignore = erase(this->size() - 1U);
1085 }
1086
1087 /// @brief Copy the string into the specified buffer up to the specified maximum length.
1088 ///
1089 /// @param str A pointer to the target buffer
1090 /// @param count The maximum number of characters to copy
1091 /// @return The number of characters copied
1092 /// @pre @c str+n must be valid , else behavior is undefined.
1093 constexpr auto copy(detail::character* str, size_type count) const -> size_type {
1094 return string_view{*this}.copy(str, count);
1095 }
1096
1097 /// @brief Copy the substring starting at the specified position into the specified buffer up to the specified maximum
1098 /// length.
1099 ///
1100 /// @param str A pointer to the target buffer
1101 /// @param count The maximum number of characters to copy
1102 /// @param pos The starting position to copy from. If @c >size() , no characters are copied.
1103 /// @return The number of characters copied
1104 /// @pre @c str[min(count,size()-pos)] must be valid , else behavior is undefined.
1105 constexpr auto copy(detail::character* str, size_type count, size_type pos) const -> size_type {
1106 return string_view{*this}.copy(str, count, pos);
1107 }
1108
1109 /// @brief Produce a copy of the string.
1110 /// @return inline_string A copy of @c *this
1111 ARENE_NODISCARD constexpr auto substr() const noexcept -> inline_string { return *this; }
1112
1113 /// @brief Produce substring of the string starting at an offset.
1114 ///
1115 /// @param pos The start of the substring to return.
1116 /// @return inline_string A new string holding the characters in the range @c [begin()+pos,end()) . If @c pos>=size()
1117 /// , returns an empty string.
1118 ARENE_NODISCARD constexpr auto substr(size_type pos) const noexcept -> inline_string {
1119 return inline_string{string_view{*this}.substr(pos)};
1120 }
1121
1122 /// @brief Produce a substring of the string with an offset and length.
1123 ///
1124 /// @param pos The start of the substring to return
1125 /// @param n The maximum number of characters to return
1126 /// @return inline_string A new string holding the characters in the range
1127 /// @c [begin()+pos,begin()+std::min(size()-pos,count)) . If @c pos>=size() , returns an empty string.
1128 ARENE_NODISCARD constexpr auto substr(size_type pos, size_type n) const noexcept -> inline_string {
1129 return inline_string{string_view{*this}.substr(pos, n)};
1130 }
1131
1132 /// @brief Check if the string is empty
1133 ///
1134 /// @return true If @c size()==0 .
1135 /// @return false If @c size()!=0 .
1136 ARENE_NODISCARD constexpr auto empty() const noexcept -> bool { return this->size() == 0U; }
1137
1138 /// @brief Return a pointer to the NUL-terminated string held in @c *this
1139 ///
1140 /// @return a pointer to the NUL-terminated string held in @c *this
1141 ARENE_NODISCARD constexpr auto c_str() const noexcept -> detail::raw_c_string { return data(); }
1142
1143 /// @brief Return a pointer to the NUL-terminated string held in @c *this
1144 ///
1145 /// @return a pointer to the NUL-terminated string held in @c *this
1146 ARENE_NODISCARD constexpr auto data() const noexcept -> detail::raw_c_string { return buffer_.data(); }
1147
1148 /// @brief Return a pointer to the NUL-terminated string held in @c *this
1149 ///
1150 /// @return a pointer to the NUL-terminated string held in @c *this
1151 ARENE_NODISCARD constexpr auto data() noexcept -> detail::character* { return buffer_.data(); }
1152
1153 // parasoft-begin-suppress AUTOSAR-A2_10_1-e "False positive: 'capacity' does not hide anything"
1154 /// @brief The maximum length of the string
1155 /// @return size_type @c MaxSize
1156 static constexpr auto capacity() -> std::size_t { return MaxSize; }
1157 // parasoft-end-suppress AUTOSAR-A2_10_1-e
1158
1159 // parasoft-begin-suppress AUTOSAR-A2_10_1-e "False positive: 'max_size' does not hide anything"
1160 /// @brief The maximum length of the string
1161 /// @return size_type @c MaxSize
1162 static constexpr auto max_size() -> std::size_t { return capacity(); }
1163 // parasoft-end-suppress AUTOSAR-A2_10_1-e
1164
1165 /// @brief Clear the string, so it is empty.
1166 /// @post size()==0 .
1167 /// @post @c data()[0]=='\0' .
1168 constexpr void clear() noexcept { set_null_terminator_to(0U); }
1169
1170 /// @brief Resize the string. If the new size is larger than the old size, appending copies of @c new_char to make the
1171 /// string the required length
1172 ///
1173 /// @param new_size The new size of the string
1174 /// @param new_char The character to append if extending the string. Defaults to @c '\0' .
1175 /// @pre @c new_size<=max_size() else @c ARENE_PRECONDITION violation.
1176 // Argument order matches the order in @c std::string::resize
1177 // NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
1178 constexpr void resize(size_type new_size, detail::character new_char = '\0') noexcept {
1179 ARENE_PRECONDITION(new_size <= max_size());
1180 inline_string::iterator original_end{end()};
1181 set_null_terminator_to(new_size);
1182 ::arene::base::fill(std::min(original_end, end()), end(), new_char);
1183 }
1184
1185 // parasoft-begin-suppress AUTOSAR-A2_10_1-a "False positive: 'index' does not hide anything"
1186 /// @brief Retrieve the @c index -th character in the string.
1187 ///
1188 /// @param index The index of the character to retrieve
1189 /// @return A reference to that character
1190 /// @pre @c index<=size() else @c ARENE_PRECONDITION violation.
1191 ARENE_NODISCARD constexpr auto operator[](size_type index) const noexcept -> detail::character const& {
1192 ARENE_PRECONDITION(index <= this->size());
1193 return buffer_[index];
1194 }
1195
1196 /// @brief Retrieve the @c index -th character in the string.
1197 ///
1198 /// @param index The index of the character to retrieve
1199 /// @return A reference to that character
1200 /// @pre @c index<=size() else @c ARENE_PRECONDITION violation.
1201 /// @warning Setting @c index[size()] to anything other than @c 0 is undefined behaviour.
1202 ARENE_NODISCARD constexpr auto operator[](size_type index) noexcept -> detail::character& {
1203 ARENE_PRECONDITION(index <= this->size());
1204 return buffer_[index];
1205 }
1206 // parasoft-end-suppress AUTOSAR-A2_10_1-a
1207
1208 /// @brief Get the first character in the string
1209 ///
1210 /// @return A reference to the first character
1211 /// @pre @c size()>0 , else @c ARENE_PRECONDITION violation.
1212 ARENE_NODISCARD constexpr auto front() const noexcept -> detail::character const& {
1214 return buffer_.front();
1215 }
1216
1217 /// @brief Get the first character in the string
1218 ///
1219 /// @return A reference to the first character
1220 /// @pre @c size()>0 , else @c ARENE_PRECONDITION violation.
1221 ARENE_NODISCARD constexpr auto front() noexcept -> detail::character& {
1223 return buffer_.front();
1224 }
1225
1226 /// @brief Get the last character in the string
1227 ///
1228 /// @return A reference to the last character
1229 /// @pre @c size()>0 , else @c ARENE_PRECONDITION violation.
1230 ARENE_NODISCARD constexpr auto back() const noexcept -> detail::character const& {
1232 return buffer_[this->size() - 1U];
1233 }
1234
1235 /// @brief Get the last character in the string
1236 ///
1237 /// @return A reference to the last character
1238 /// @pre @c size()>0 , else @c ARENE_PRECONDITION violation.
1239 ARENE_NODISCARD constexpr auto back() noexcept -> detail::character& {
1241 return buffer_[this->size() - 1U];
1242 }
1243
1244 // parasoft-begin-suppress AUTOSAR-A2_10_1-d "False positive: identifier 'begin' does not hide anything"
1245 /// @brief Iterator to the first position in the string.
1246 ///
1247 /// @return iterator An iterator to that refers to the first element if the string is not empty, or @c end()
1248 /// otherwise
1249 ARENE_NODISCARD constexpr auto begin() noexcept -> iterator {
1250 return iterator(iterator_passkey{}, buffer_.begin().base());
1251 }
1252
1253 /// @brief Iterator to the first position in the string.
1254 ///
1255 /// @return const_iterator An iterator to that refers to the first element if the string is not empty, or @c end()
1256 /// otherwise
1257 ARENE_NODISCARD constexpr auto begin() const noexcept -> const_iterator {
1258 return const_iterator(iterator_passkey{}, buffer_.begin().base());
1259 }
1260 /// @brief Iterator to the first position in the string.
1261 ///
1262 /// @return const_iterator An iterator to that refers to the first element if the string is not empty, or @c end()
1263 /// otherwise
1264 ARENE_NODISCARD constexpr auto cbegin() const noexcept -> const_iterator { return begin(); }
1265 // parasoft-end-suppress AUTOSAR-A2_10_1-d
1266
1267 // parasoft-begin-suppress AUTOSAR-A2_10_1-d "False positive: identifier 'end' does not hide anything"
1268 /// @brief The one-past-the-last position in the string.
1269 ///
1270 /// @return iterator An iterator to that refers to one-past-the-last position in the string.
1271 ARENE_NODISCARD constexpr auto end() noexcept -> iterator {
1272 return begin() + static_cast<difference_type>(this->size());
1273 }
1274
1275 /// @brief Return an iterator to one-past-the-last position in the string.
1276 ///
1277 /// @return const_iterator An iterator to that refers to one-past-the-last position in the string.
1278 ARENE_NODISCARD constexpr auto end() const noexcept -> const_iterator {
1279 return begin() + static_cast<difference_type>(this->size());
1280 }
1281 /// @brief Return an iterator to one-past-the-last position in the string.
1282 ///
1283 /// @return const_iterator An iterator to that refers to one-past-the-last position in the string.
1284 ARENE_NODISCARD constexpr auto cend() const noexcept -> const_iterator { return end(); }
1285 // parasoft-end-suppress AUTOSAR-A2_10_1-d
1286
1287 /// @brief Return an iterator to the start of the reversed string
1288 ///
1289 /// @return reverse_iterator An iterator equivalent to @c reverse_iterator(end())
1290 ARENE_NODISCARD constexpr auto rbegin() noexcept -> reverse_iterator { return reverse_iterator(end()); }
1291
1292 /// @brief Return an iterator to the start of the reversed string
1293 ///
1294 /// @return const_reverse_iterator An iterator equivalent to @c const_reverse_iterator(end())
1295 ARENE_NODISCARD auto rbegin() const noexcept -> const_reverse_iterator { return const_reverse_iterator(end()); }
1296
1297 /// @brief Return an iterator to the start of the reversed string
1298 ///
1299 /// @return const_reverse_iterator An iterator equivalent to @c const_reverse_iterator(end())
1300 ARENE_NODISCARD auto crbegin() const noexcept -> const_reverse_iterator { return rbegin(); }
1301
1302 /// @brief Return an iterator to the end of the reversed string
1303 ///
1304 /// @return reverse_iterator An iterator equivalent to @c reverse_iterator(begin())
1305 ARENE_NODISCARD constexpr auto rend() noexcept -> reverse_iterator { return reverse_iterator(begin()); }
1306
1307 /// @brief Return an iterator to the end of the reversed string
1308 ///
1309 /// @return const_reverse_iterator An iterator equivalent to @c const_reverse_iterator(begin())
1310 ARENE_NODISCARD auto rend() const noexcept -> const_reverse_iterator { return const_reverse_iterator(begin()); }
1311
1312 /// @brief Return an iterator to the end of the reversed string
1313 ///
1314 /// @return const_reverse_iterator An iterator equivalent to @c const_reverse_iterator(begin())
1315 ARENE_NODISCARD auto crend() const noexcept -> const_reverse_iterator { return rend(); }
1316
1317 // parasoft-begin-suppress AUTOSAR-A2_10_1-e "These functions are called with qualified names so they can't be hidden"
1318 /// @brief Compare two strings for lexicographical ordering.
1319 ///
1320 /// @tparam OtherMaxLength The max length of the other string
1321 /// @param lhs The first string
1322 /// @param rhs The second string
1323 /// @return strong_ordering::equal If both strings have the same @c size() and equivalent characters.
1324 /// @return strong_ordering::less If @c lhs is lexicographically before @c rhs .
1325 /// @return strong_ordering::greater If @c lhs is lexicographically after @c rhs .
1326 template <std::size_t OtherMaxLength>
1327 ARENE_NODISCARD static constexpr auto
1331
1332 /// @brief Compare two strings for lexicographical ordering.
1333 ///
1334 /// @param lhs The first string
1335 /// @param rhs The second string
1336 /// @return strong_ordering::equal If both strings have the same @c size() and equivalent characters.
1337 /// @return strong_ordering::less If @c lhs is lexicographically before @c rhs .
1338 /// @return strong_ordering::greater If @c lhs is lexicographically after @c rhs .
1339 ARENE_NODISCARD static constexpr auto three_way_compare(inline_string const& lhs, string_view rhs) noexcept
1340 -> strong_ordering {
1342 }
1343
1344 /// @brief Compare two strings for lexicographical ordering.
1345 ///
1346 /// @param lhs The first string
1347 /// @param rhs The second string
1348 /// @return strong_ordering::equal If both strings have the same @c size() and equivalent characters.
1349 /// @return strong_ordering::less If @c lhs is lexicographically before @c rhs .
1350 /// @return strong_ordering::greater If @c lhs is lexicographically after @c rhs .
1351 ARENE_NODISCARD static constexpr auto three_way_compare(inline_string const& lhs, detail::raw_c_string rhs) noexcept
1352 -> strong_ordering {
1354 }
1355
1356 /// @brief Compare two strings for lexicographical ordering.
1357 ///
1358 /// @param lhs The first string
1359 /// @param rhs The second string
1360 /// @return strong_ordering::equal If both strings have the same @c size() and equivalent characters.
1361 /// @return strong_ordering::less If @c lhs is lexicographically before @c rhs .
1362 /// @return strong_ordering::greater If @c lhs is lexicographically after @c rhs .
1363 ARENE_NODISCARD static constexpr auto
1365 return inline_string::three_way_compare(lhs, rhs.c_str());
1366 }
1367
1368 /// @brief Determine if two strings are definitely not equal.
1369 ///
1370 /// @tparam OtherMaxLength The max length of the second string
1371 /// @param lhs The first string
1372 /// @param rhs The second string
1373 /// @return inequality_heuristic::definitely_not_equal If @c lhs.size()!=rhs.size() .
1374 /// @return inequality_heuristic::may_be_equal_or_not_equal If @c lhs.size()==rhs.size() .
1375 template <std::size_t OtherMaxLength>
1376 ARENE_NODISCARD static constexpr auto
1381
1382 /// @brief Determine if two strings are definitely not equal.
1383 ///
1384 /// @param lhs The first string
1385 /// @param rhs The second string
1386 /// @return inequality_heuristic::definitely_not_equal If @c lhs.size()!=rhs.size() .
1387 /// @return inequality_heuristic::may_be_equal_or_not_equal If @c lhs.size()==rhs.size() .
1388 ARENE_NODISCARD static constexpr auto fast_inequality_check(inline_string const& lhs, string_view rhs) noexcept
1390 return inline_string_base::common_fast_inequality_check(lhs, rhs);
1391 }
1392 // parasoft-end-suppress AUTOSAR-A2_10_1-e
1393
1394 /// @brief Append a string to the current string
1395 ///
1396 /// @param rhs The string to append
1397 /// @return inline_string& @c *this
1398 /// @pre @c size()+rhs.size()<=max_size() else @c ARENE_PRECONDITION violation.
1399 /// @post @c size() is increased by @c rhs.size()
1400 /// @post The final characters in the string will be a substring equivalent to @c rhs .
1401 constexpr auto append(string_view rhs) noexcept -> inline_string& {
1402 ARENE_PRECONDITION(this->size() + rhs.size() <= max_size());
1403 std::ignore = ::arene::base::copy(rhs.begin(), rhs.end(), begin() + static_cast<difference_type>(this->size()));
1404 set_null_terminator_to(this->size() + rhs.size());
1405 return *this;
1406 }
1407
1408 /// @brief Append a character to the current string
1409 ///
1410 /// @param rhs The character to append
1411 /// @return inline_string& @c *this
1412 /// @pre @c size()+1<=max_size() else @c ARENE_PRECONDITION violation.
1413 /// @post @c size() is increased by @c 1
1414 /// @post @c back()==rhs
1415 constexpr auto append(detail::character rhs) noexcept -> inline_string& { return append(string_view{&rhs, 1U}); }
1416
1417 /// @brief Append a series of characters from an initializer list to the string.
1418 ///
1419 /// @param rhs The characters to append
1420 /// @return inline_string& @c *this
1421 /// @pre @c size()+rhs.size()<=max_size() else @c ARENE_PRECONDITION violation.
1422 /// @post @c size() is increased by @c rhs.size()
1423 /// @post The final characters in the string will be a substring equivalent to @c rhs .
1425 return append(string_view{rhs.begin(), rhs.size()});
1426 }
1427
1428 /// @brief Append a substring of a string to the current string
1429 ///
1430 /// @param rhs The string containing the substring to append
1431 /// @param pos The offset into @c rhs of the substring to append
1432 /// @return inline_string& @c *this
1433 /// @pre @c size()+rhs.substr(pos).size()<=max_size() else @c ARENE_PRECONDITION violation.
1434 /// @post @c size() is increased by @c rhs.substr(pos).size()
1435 /// @post The final characters in the string will be a substring equivalent to @c rhs.substr(pos) .
1436 constexpr auto append(string_view rhs, size_type pos) noexcept -> inline_string& { return append(rhs.substr(pos)); }
1437
1438 /// @brief Append a substring of a string to the current string
1439 ///
1440 /// @param rhs The string containing the substring to append
1441 /// @param pos The offset into @c rhs of the substring to append
1442 /// @param count The maximum length of the substring to append
1443 /// @return inline_string& @c *this
1444 /// @pre @c size()+rhs.substr(pos,count).size()<=max_size() else @c ARENE_PRECONDITION violation.
1445 /// @post @c size() is increased by @c rhs.substr(pos,count).size()
1446 /// @post The final characters in the string will be a substring equivalent to @c rhs.substr(pos,count) .
1447 constexpr auto append(string_view rhs, size_type pos, size_type count) noexcept -> inline_string& {
1448 return append(rhs.substr(pos, count));
1449 }
1450
1451 /// @brief Append a string specified as pointer and length to the current string
1452 ///
1453 /// @param rhs The start if the string to append
1454 /// @param count The number of characters in the string to append
1455 /// @return inline_string& @c *this
1456 /// @pre @c size()+count<=max_size() else @c ARENE_PRECONDITION violation.
1457 /// @post @c size() is increased by @c count
1458 /// @post The last @c count characters in the string are the @c count characters from @c rhs .
1459 constexpr auto append(detail::raw_c_string rhs, size_type count) noexcept -> inline_string& {
1460 return append(string_view{rhs, count});
1461 }
1462
1463 /// @brief Append the specified number of copies of a character to the string
1464 ///
1465 /// @param count The number of characters to append
1466 /// @param chr The character to append
1467 /// @return inline_string& @c *this
1468 /// @pre @c size()+count<=max_size() else @c ARENE_PRECONDITION violation.
1469 /// @post @c size() is increased by @c count
1470 /// @post The last @c count characters in the string are @c chr .
1471 // Argument order matches the order in @c std::string::append
1472 // NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
1473 constexpr auto append(size_type count, detail::character chr) noexcept -> inline_string& {
1474 resize(this->size() + count, chr);
1475 return *this;
1476 }
1477
1478 /// @brief Append a character to the current string
1479 ///
1480 /// @param rhs The character to append
1481 /// @pre @c size()+1<=max_size() else @c ARENE_PRECONDITION violation.
1482 /// @post @c size() is increased by @c 1
1483 /// @post @c back()==rhs
1484 constexpr void push_back(detail::character rhs) noexcept { std::ignore = append(rhs); }
1485
1486 /// @brief Append a string to the current string
1487 ///
1488 /// @param rhs The string to append
1489 /// @return inline_string& @c *this
1490 /// @pre @c size()+rhs.size()<=max_size() else @c ARENE_PRECONDITION violation.
1491 /// @post @c size() is increased by @c rhs.size()
1492 /// @post The final characters in the string will be a substring equivalent to @c rhs .
1493 constexpr auto operator+=(string_view rhs) noexcept -> inline_string& { return append(rhs); }
1494
1495 /// @brief Append a character to the current string
1496 ///
1497 /// @param rhs The character to append
1498 /// @return inline_string& @c *this
1499 /// @pre @c size()+1<=max_size() else @c ARENE_PRECONDITION violation.
1500 /// @post @c size() is increased by @c 1
1501 /// @post @c back()==rhs
1502 constexpr auto operator+=(detail::character rhs) noexcept -> inline_string& { return append(rhs); }
1503
1504 /// @brief Append a series of characters from an initializer list to the string.
1505 ///
1506 /// @param rhs The characters to append
1507 /// @return inline_string& @c *this
1508 /// @pre @c size()+rhs.size()<=max_size() else @c ARENE_PRECONDITION violation.
1509 /// @post @c size() is increased by @c rhs.size()
1510 /// @post The final characters in the string will be a substring equivalent to @c rhs .
1512 return append(rhs);
1513 }
1514
1515 // parasoft-begin-suppress AUTOSAR-A13_5_2-a-2 "Implicit conversion to string_view is part of the API"
1516 /// @brief Convert to string view
1517 ///
1518 /// Implicit conversion to @c string_view supports the use of @c string_view as a vocabulary type for accepting string
1519 /// parameters.
1520 /// @return A string view referring to the characters of @c *this
1521 // NOLINTNEXTLINE(google-explicit-constructor,hicpp-explicit-conversions)
1522 ARENE_NODISCARD constexpr operator string_view() const noexcept {
1523 // We specify MaxLength as a maximum valid value to eliminate the
1524 // precondition in base::span constructor.
1525 return {c_str(), std::min(this->size(), max_size())};
1526 }
1527 // parasoft-end-suppress AUTOSAR-A13_5_2-a-2
1528
1529 // parasoft-begin-suppress AUTOSAR-A13_5_2-a-2 "Implicit conversion to null_terminated_string_view is part of the API"
1530 /// @brief Convert to null terminated string view
1531 ///
1532 /// Implicit conversion to @c null_terminated_string_view supports the use of @c null_terminated_string_view as a
1533 /// vocabulary type for accepting string parameters.
1534 /// @return A null-terminated string view referring to the characters of @c *this
1535 // NOLINTNEXTLINE(google-explicit-constructor,hicpp-explicit-conversions)
1536 ARENE_NODISCARD constexpr operator null_terminated_string_view() const noexcept {
1538 }
1539 // parasoft-end-suppress AUTOSAR-A13_5_2-a-2
1540
1541 /// @brief Find the earliest position of the given substring within the string, starting at the specified position.
1542 ///
1543 /// @param str The substring to search for.
1544 /// @param pos The lowest position to search from. Defaults to 0.
1545 /// @return size_type The offset at which @c str can be found within the string, or @c npos if not found.
1546 ARENE_NODISCARD constexpr auto find(string_view str, size_type pos = 0U) const noexcept -> size_type {
1547 return string_view{*this}.find(str, pos);
1548 }
1549
1550 /// @brief Find the earliest position of the specified character within the string.
1551 ///
1552 /// @param chr The character to search for
1553 /// @return The position of that character, or @c npos if not found
1554 ARENE_NODISCARD constexpr auto find(detail::character chr) const noexcept -> size_type {
1555 return find(string_view{&chr, 1U});
1556 }
1557
1558 /// @brief Find the earliest position of the specified character within the string, starting at the specified position
1559 ///
1560 /// @param chr The character to search for
1561 /// @param pos The lowest position to search from
1562 /// @return The position of that character, or @c npos if not found
1563 ARENE_NODISCARD constexpr auto find(detail::character chr, size_type pos) const noexcept -> size_type {
1564 return find(string_view{&chr, 1U}, pos);
1565 }
1566
1567 /// @brief Find the earliest position of the given substring within the string.
1568 ///
1569 /// @param str The substring to search for
1570 /// @return size_type The offset at which @c str can be found within the string, or @c npos if not found.
1571 ARENE_NODISCARD constexpr auto find(detail::raw_c_string str) const noexcept -> size_type {
1572 return find(string_view{str});
1573 }
1574
1575 /// @brief Find the earliest position of the given substring within the string, starting at the specified position
1576 ///
1577 /// @param str The substring to search for
1578 /// @param pos The lowest position to search from
1579 /// @return size_type The offset at which @c str can be found within the string, or @c npos if not found.
1580 ARENE_NODISCARD constexpr auto find(detail::raw_c_string str, size_type pos) const noexcept -> size_type {
1581 return find(string_view{str}, pos);
1582 }
1583
1584 /// @brief Find the earliest position of the @c n character string starting at @c str within the string, starting at
1585 /// the specified position
1586 ///
1587 /// @param str The start of the string to search for
1588 /// @param pos The lowest position to search from
1589 /// @param count The length of the string to search for
1590 /// @return size_type The offset at which @c str can be found within the string, or @c npos if not found.
1591 ARENE_NODISCARD constexpr auto find(detail::raw_c_string str, size_type pos, size_type count) const noexcept
1592 -> size_type {
1593 return find(string_view{str, count}, pos);
1594 }
1595
1596 /// @brief Find the latest position of the given substring within the string.
1597 ///
1598 /// @param str The substring to search for
1599 /// @return size_type The offset at which @c str can be found within the string, or @c npos if not found.
1600 ARENE_NODISCARD constexpr auto rfind(string_view str) const noexcept -> size_type { return rfind(str, this->size()); }
1601
1602 /// @brief Find the latest position of the given substring within the string, starting at the specified position
1603 ///
1604 /// @param str The substring to search for
1605 /// @param pos The highest position to search from
1606 /// @return size_type The offset at which @c str can be found within the string, or @c npos if not found.
1607 ARENE_NODISCARD constexpr auto rfind(string_view str, size_type pos) const noexcept -> size_type {
1608 return string_view{*this}.rfind(str, pos);
1609 }
1610
1611 /// @brief Find the latest position of the specified character within the string
1612 ///
1613 /// @param chr The character to search for
1614 /// @return The position of that character, or @c npos if not found
1615 ARENE_NODISCARD constexpr auto rfind(detail::character chr) const noexcept -> size_type {
1616 return rfind(string_view{&chr, 1U});
1617 }
1618
1619 /// @brief Find the latest position of the specified character within the string, starting at the specified position.
1620 ///
1621 /// @param chr The character to search for
1622 /// @param pos The highest position to search from
1623 /// @return The position of that character, or @c npos if not found
1624 ARENE_NODISCARD constexpr auto rfind(detail::character chr, size_type pos) const noexcept -> size_type {
1625 return rfind(string_view{&chr, 1U}, pos);
1626 }
1627
1628 /// @brief Find the latest position of the given substring within the string.
1629 ///
1630 /// @param str The substring to search for
1631 /// @return size_type The offset at which @c str can be found within the string, or @c npos if not found.
1632 ARENE_NODISCARD constexpr auto rfind(detail::raw_c_string str) const noexcept -> size_type {
1633 return rfind(string_view{str});
1634 }
1635
1636 /// @brief Find the latest position of the given substring within the string, starting at the specified position
1637 ///
1638 /// @param str The substring to search for
1639 /// @param pos The highest position to search from
1640 /// @return size_type The offset at which @c str can be found within the string, or @c npos if not found.
1641 ARENE_NODISCARD constexpr auto rfind(detail::raw_c_string str, size_type pos) const noexcept -> size_type {
1642 return rfind(string_view{str}, pos);
1643 }
1644
1645 /// @brief Find the latest position of the @c n character string starting at @c str within the string, starting at the
1646 /// specified position
1647 ///
1648 /// @param str The start of the string to search for
1649 /// @param pos The highest position to search from
1650 /// @param count The length of the string to search for
1651 /// @return size_type The offset at which @c str can be found within the string, or @c npos if not found.
1652 ARENE_NODISCARD constexpr auto rfind(detail::raw_c_string str, size_type pos, size_type count) const noexcept
1653 -> size_type {
1654 return rfind(string_view{str, count}, pos);
1655 }
1656
1657 /// @brief Find the earliest position such that the character at that position is one of those in the provided string.
1658 ///
1659 /// @param str The list of characters to find
1660 /// @return The offset of the first character in @c str if there is one, otherwise @c npos
1661 ARENE_NODISCARD constexpr auto find_first_of(string_view str) const noexcept -> size_type {
1662 return find_first_of(str, 0U);
1663 }
1664
1665 /// @brief Find the earliest position from the provided start position onwards such that the character at that
1666 /// position is one of those in the provided string.
1667 ///
1668 /// @param str The list of characters to find
1669 /// @param pos The start position
1670 /// @return The offset of the first character in @c str after @c pos if there is one, otherwise @c npos
1671 ARENE_NODISCARD constexpr auto find_first_of(string_view str, size_type pos) const noexcept -> size_type {
1672 return string_view{*this}.find_first_of(str, pos);
1673 }
1674
1675 /// @brief Find the earliest position such that the character at that position is one of those in the provided string.
1676 ///
1677 /// @param str The list of characters to find
1678 /// @return The offset of the first character in @c str if there is one, otherwise @c npos
1679 ARENE_NODISCARD constexpr auto find_first_of(detail::raw_c_string str) const noexcept -> size_type {
1680 return find_first_of(string_view{str}, 0U);
1681 }
1682
1683 /// @brief Find the earliest position from the provided start position onwards such that the character at that
1684 /// position is one of those in the provided string.
1685 ///
1686 /// @param str The list of characters to find
1687 /// @param pos The start position
1688 /// @return The offset of the first character in @c str after @c pos if there is one, otherwise @c npos
1689 ARENE_NODISCARD constexpr auto find_first_of(detail::raw_c_string str, size_type pos) const noexcept -> size_type {
1690 return find_first_of(string_view{str}, pos);
1691 }
1692
1693 /// @brief Find the earliest position from the provided start position onwards such that the character at that
1694 /// position is one of those in the provided string.
1695 ///
1696 /// @param str The list of characters to find
1697 /// @param pos The start position
1698 /// @param count The number of characters in @c str
1699 /// @return The offset of the first character in @c str after @c pos if there is one, otherwise @c npos
1700 ARENE_NODISCARD constexpr auto find_first_of(detail::raw_c_string str, size_type pos, size_type count) const noexcept
1701 -> size_type {
1702 return find_first_of(string_view{str, count}, pos);
1703 }
1704
1705 /// @brief Find the earliest position such that the character at that position is the provided character.
1706 ///
1707 /// @param chr The character to find
1708 /// @return The offset of the first character matching @c chr if there is one, otherwise @c npos
1709 ARENE_NODISCARD constexpr auto find_first_of(detail::character chr) const noexcept -> size_type { return find(chr); }
1710
1711 /// @brief Find the earliest position from the provided start position onwards such that the character at that
1712 /// position is the provided character.
1713 ///
1714 /// @param chr The character to find
1715 /// @param pos The start position
1716 /// @return The offset of the first character matching @c chr after @c pos if there is one, otherwise @c npos
1717 ARENE_NODISCARD constexpr auto find_first_of(detail::character chr, size_type pos) const noexcept -> size_type {
1718 return find(chr, pos);
1719 }
1720
1721 /// @brief Find the earliest position such that the character at that position is not one of those in the provided
1722 /// string.
1723 ///
1724 /// @param str The list of characters to find
1725 /// @return The offset of the first character not in @c str if there is one, otherwise @c npos
1726 ARENE_NODISCARD constexpr auto find_first_not_of(string_view str) const noexcept -> size_type {
1727 return find_first_not_of(str, 0U);
1728 }
1729
1730 /// @brief Find the earliest position from the provided start position onwards such that the character at that
1731 /// position is one of those in the provided string.
1732 ///
1733 /// @param str The list of characters to find
1734 /// @param pos The start position
1735 /// @return The offset of the first character not in @c str after @c pos if there is one, otherwise @c npos
1736 ARENE_NODISCARD constexpr auto find_first_not_of(string_view str, size_type pos) const noexcept -> size_type {
1737 return string_view{*this}.find_first_not_of(str, pos);
1738 }
1739
1740 /// @brief Find the earliest position such that the character at that position is not one of those in the provided
1741 /// string.
1742 ///
1743 /// @param str The list of characters to find
1744 /// @return The offset of the first character not in @c str if there is one, otherwise @c npos
1745 ARENE_NODISCARD constexpr auto find_first_not_of(detail::raw_c_string str) const noexcept -> size_type {
1746 return find_first_not_of(string_view{str}, 0U);
1747 }
1748
1749 /// @brief Find the earliest position from the provided start position onwards such that the character at that
1750 /// position is not one of those in the provided string.
1751 ///
1752 /// @param str The list of characters to find
1753 /// @param pos The start position
1754 /// @return The offset of the first character not in @c str after @c pos if there is one, otherwise @c npos
1755 ARENE_NODISCARD constexpr auto find_first_not_of(detail::raw_c_string str, size_type pos) const noexcept
1756 -> size_type {
1757 return find_first_not_of(string_view{str}, pos);
1758 }
1759
1760 /// @brief Find the earliest position from the provided start position onwards such that the character at that
1761 /// position is not one of those in the provided string.
1762 ///
1763 /// @param str The list of characters to find
1764 /// @param pos The start position
1765 /// @param count The number of characters in @c str
1766 /// @return The offset of the first character not in @c str after @c pos if there is one, otherwise @c npos
1767 ARENE_NODISCARD constexpr auto find_first_not_of(detail::raw_c_string str, size_type pos, size_type count)
1768 const noexcept -> size_type {
1769 return find_first_not_of(string_view{str, count}, pos);
1770 }
1771
1772 /// @brief Find the earliest position such that the character at that position is the provided character.
1773 ///
1774 /// @param chr The character to find
1775 /// @return The offset of the first character not matching @c chr if there is one, otherwise @c npos
1776 ARENE_NODISCARD constexpr auto find_first_not_of(detail::character chr) const noexcept -> size_type {
1777 return find_first_not_of(string_view{&chr, 1U});
1778 }
1779
1780 /// @brief Find the earliest position from the provided start position onwards such that the character at that
1781 /// position is not the provided character.
1782 ///
1783 /// @param chr The character to find
1784 /// @param pos The start position
1785 /// @return The offset of the first character not matching @c chr after @c pos if there is one, otherwise @c npos
1786 ARENE_NODISCARD constexpr auto find_first_not_of(detail::character chr, size_type pos) const noexcept -> size_type {
1787 return find_first_not_of(string_view{&chr, 1U}, pos);
1788 }
1789
1790 /// @brief Find the last position such that the character at that position is one of those in the provided string.
1791 ///
1792 /// @param str The list of characters to find
1793 /// @return The offset of the last character matching those in @c str if there is one, otherwise @c npos
1794 ARENE_NODISCARD constexpr auto find_last_of(string_view str) const noexcept -> size_type {
1795 return find_last_of(str, npos);
1796 }
1797
1798 /// @brief Find the last position from the provided start position backwards such that the character at that position
1799 /// is one of those in the provided string.
1800 ///
1801 /// @param str The list of characters to find
1802 /// @param pos The start position
1803 /// @return The offset of the last character matching those in @c str before or at @c pos if there is one, otherwise
1804 /// @c npos
1805 ARENE_NODISCARD constexpr auto find_last_of(string_view str, size_type pos) const noexcept -> size_type {
1806 return string_view{*this}.find_last_of(str, pos);
1807 }
1808
1809 /// @brief Find the last position such that the character at that position is one of those in the provided string.
1810 ///
1811 /// @param str The list of characters to find
1812 /// @return The offset of the last character in @c str if there is one, otherwise @c npos
1813 ARENE_NODISCARD constexpr auto find_last_of(detail::raw_c_string str) const noexcept -> size_type {
1814 return find_last_of(string_view{str}, npos);
1815 }
1816
1817 /// @brief Find the last position from the provided start position backwards such that the character at that position
1818 /// is one of those in the provided string.
1819 ///
1820 /// @param str The list of characters to find
1821 /// @param pos The start position
1822 /// @return The offset of the last character matching the characters in @c str at or before @c pos if there is one,
1823 /// otherwise @c npos
1824 ARENE_NODISCARD constexpr auto find_last_of(detail::raw_c_string str, size_type pos) const noexcept -> size_type {
1825 return find_last_of(string_view{str}, pos);
1826 }
1827
1828 /// @brief Find the latest position from the provided start position backwards such that the character at that
1829 /// position is one of those in the provided string.
1830 ///
1831 /// @param str The list of characters to find
1832 /// @param pos The start position
1833 /// @param count The number of characters in @c str
1834 /// @return The offset of the last character matching the characters in the first @c n characters of @c str at or
1835 /// before @c pos if there is one, otherwise @c npos
1836 ARENE_NODISCARD constexpr auto find_last_of(detail::raw_c_string str, size_type pos, size_type count) const noexcept
1837 -> size_type {
1838 return find_last_of(string_view{str, count}, pos);
1839 }
1840
1841 /// @brief Find the latest position such that the character at that position is the provided character.
1842 ///
1843 /// @param chr The character to find
1844 /// @return The offset of the last character matching @c chr if there is one, otherwise @c npos
1845 ARENE_NODISCARD constexpr auto find_last_of(detail::character chr) const noexcept -> size_type { return rfind(chr); }
1846
1847 /// @brief Find the latest position from the provided start position backwards such that the character at that
1848 /// position is the provided character.
1849 ///
1850 /// @param chr The character to find
1851 /// @param pos The start position
1852 /// @return The offset of the last character matching @c chr at or before @c pos if there is one, otherwise @c npos
1853 ARENE_NODISCARD constexpr auto find_last_of(detail::character chr, size_type pos) const noexcept -> size_type {
1854 return rfind(chr, pos);
1855 }
1856
1857 /// @brief Find the latest position such that the character at that position is not one of those in the provided
1858 /// string.
1859 ///
1860 /// @param str The list of characters to find
1861 /// @return The offset of the last character not in @c str if there is one, otherwise @c npos
1862 ARENE_NODISCARD constexpr auto find_last_not_of(string_view str) const noexcept -> size_type {
1863 return find_last_not_of(str, npos);
1864 }
1865
1866 /// @brief Find the latest position from the provided start position backwards such that the character at that
1867 /// position is not one of those in the provided string.
1868 ///
1869 /// @param str The list of characters to find
1870 /// @param pos The start position
1871 /// @return The offset of the last character not in @c str at or before @c pos if there is one, otherwise @c npos
1872 ARENE_NODISCARD constexpr auto find_last_not_of(string_view str, size_type pos) const noexcept -> size_type {
1873 return string_view{*this}.find_last_not_of(str, pos);
1874 }
1875
1876 /// @brief Find the latest position such that the character at that position is not one of those in the provided
1877 /// string.
1878 ///
1879 /// @param str The list of characters to find
1880 /// @return The offset of the last character not in @c str if there is one, otherwise @c npos
1881 ARENE_NODISCARD constexpr auto find_last_not_of(detail::raw_c_string str) const noexcept -> size_type {
1882 return find_last_not_of(string_view{str});
1883 }
1884
1885 /// @brief Find the latest position from the provided start position backwards such that the character at that
1886 /// position is not one of those in the provided string.
1887 ///
1888 /// @param str The list of characters to find
1889 /// @param pos The start position
1890 /// @return The offset of the last character not in @c str at or before @c pos if there is one, otherwise @c npos
1891 ARENE_NODISCARD constexpr auto find_last_not_of(detail::raw_c_string str, size_type pos) const noexcept -> size_type {
1892 return find_last_not_of(string_view{str}, pos);
1893 }
1894
1895 /// @brief Find the latest position from the provided start position backwards such that the character at that
1896 /// position is not one of those in the provided string.
1897 ///
1898 /// @param str The list of characters to find
1899 /// @param pos The start position
1900 /// @param count The number of characters in @c str
1901 /// @return The offset of the last character not in @c str at or before @c pos if there is one, otherwise @c npos
1902 ARENE_NODISCARD constexpr auto find_last_not_of(detail::raw_c_string str, size_type pos, size_type count)
1903 const noexcept -> size_type {
1904 return find_last_not_of(string_view{str, count}, pos);
1905 }
1906
1907 /// @brief Find the latest position such that the character at that position is not the provided character.
1908 ///
1909 /// @param chr The character to find
1910 /// @return The offset of the last character not matching @c chr if there is one, otherwise @c npos
1911 ARENE_NODISCARD constexpr auto find_last_not_of(detail::character chr) const noexcept -> size_type {
1912 return find_last_not_of(string_view{&chr, 1U});
1913 }
1914
1915 /// @brief Find the latest position from the provided start position backwards such that the character at that
1916 /// position is not the provided character.
1917 ///
1918 /// @param chr The character to find
1919 /// @param pos The start position
1920 /// @return The offset of the last character not matching @c chr at or before @c pos if there is one, otherwise
1921 /// @c npos
1922 ARENE_NODISCARD constexpr auto find_last_not_of(detail::character chr, size_type pos) const noexcept -> size_type {
1923 return find_last_not_of(string_view{&chr, 1U}, pos);
1924 }
1925
1926 /// @brief Check if the string starts with a character.
1927 ///
1928 /// @param chr The character to check
1929 /// @return inline_string @c true if the string starts with the character, @c false otherwise
1930 ARENE_NODISCARD constexpr auto starts_with(detail::character chr) const noexcept -> bool {
1931 return string_view{*this}.starts_with(chr);
1932 }
1933
1934 /// @brief Check if the string starts with another string.
1935 ///
1936 /// @param str The string to check
1937 /// @return inline_string @c true if the string starts with the string, @c false otherwise
1938 ARENE_NODISCARD constexpr auto starts_with(string_view str) const noexcept -> bool {
1939 return string_view{*this}.starts_with(str);
1940 }
1941
1942 /// @brief Check if the string ends with a character.
1943 ///
1944 /// @param chr The character to check
1945 /// @return inline_string @c true if the string ends with the character, @c false otherwise
1946 ARENE_NODISCARD constexpr auto ends_with(detail::character chr) const noexcept -> bool {
1947 return string_view{*this}.ends_with(chr);
1948 }
1949
1950 /// @brief Check if the string ends with another string.
1951 ///
1952 /// @param str The string to check
1953 /// @return inline_string @c true if the string ends with the string, @c false otherwise
1954 ARENE_NODISCARD constexpr auto ends_with(string_view str) const noexcept -> bool {
1955 return string_view{*this}.ends_with(str);
1956 }
1957
1958 /// @brief Compare against another string, to see if it is less than, equal to or greater than the other.
1959 ///
1960 /// @param other The other string
1961 /// @return inline_string @c -1 if @c *this is less than @c other, @c 0 if they are equal, and @c 1 if @c *this is
1962 /// greater than @c other
1963 ARENE_NODISCARD constexpr auto compare(string_view other) const noexcept -> integral_comparison_result {
1964 return string_view{*this}.compare(other);
1965 }
1966
1967 /// @brief Compare a substring against another string, to see if it is less than, equal to or greater than the other.
1968 ///
1969 /// @param pos The start of the substring to compare
1970 /// @param count The length of the substring to compare
1971 /// @param other The other string
1972 /// @return inline_string @c substr(pos,n).compare(other)
1973 ARENE_NODISCARD constexpr auto compare(size_type pos, size_type count, string_view other) const noexcept
1974 -> integral_comparison_result {
1975 return string_view{*this}.substr(pos, count).compare(other);
1976 }
1977
1978 /// @brief Compare a substring against a substring of another string, to see if it is less than, equal to or greater
1979 /// than the other.
1980 ///
1981 /// @param pos The start of the substring to compare
1982 /// @param count The length of the substring to compare
1983 /// @param other The other string
1984 /// @param pos2 The start of the substring in the other string
1985 /// @return inline_string @c compare(pos,n,other.substr(pos2))
1986 ARENE_NODISCARD constexpr auto compare(size_type pos, size_type count, string_view other, size_type pos2)
1987 const noexcept -> integral_comparison_result {
1988 return compare(pos, count, other.substr(pos2));
1989 }
1990
1991 /// @brief Compare a substring against a substring of another string, to see if it is less than, equal to or greater
1992 /// than the other.
1993 ///
1994 /// @param pos The start of the substring to compare
1995 /// @param length1 The length of the substring to compare
1996 /// @param other The other string
1997 /// @param pos2 The start of the substring in the other string
1998 /// @param length2 The length of the substring in the other string
1999 /// @return inline_string @c compare(pos,n,other.substr(pos2,length2))
2000 ARENE_NODISCARD constexpr auto
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));
2004 }
2005
2006 /// @brief Compare a substring against another string, to see if it is less than, equal to or greater than the other.
2007 ///
2008 /// @param pos The start of the substring to compare
2009 /// @param length1 The length of the substring to compare
2010 /// @param other The start of the other string
2011 /// @param length2 The length of the other string
2012 /// @return inline_string @c compare(pos,n,string_view{other,length2})
2013 ARENE_NODISCARD constexpr auto
2014 compare(size_type pos, size_type length1, detail::raw_c_string other, size_type length2) const noexcept
2015 -> integral_comparison_result {
2016 return compare(pos, length1, string_view{other, length2});
2017 }
2018
2019 // parasoft-begin-suppress AUTOSAR-A11_3_1-a-2 "Hidden friends permitted by A11-3-1 Permit #2"
2020 /// @brief Concatenate two strings
2021 /// @tparam OtherMaxLength the max length of @c rhs
2022 /// @param lhs The first string to concatenate
2023 /// @param rhs The second string to concatenate
2024 /// @return A @c inline_string<MaxLength+OtherMaxLength> holding the concatenation of the two strings.
2025 template <std::size_t OtherMaxLength>
2026 ARENE_NODISCARD friend constexpr auto
2030 std::ignore = res.append(rhs);
2031 return res;
2032 }
2033 // parasoft-end-suppress AUTOSAR-A11_3_1-a-2
2034
2035 // parasoft-begin-suppress AUTOSAR-A0_1_3-a-2 "False positive: This is a namespace scope function"
2036 // parasoft-begin-suppress AUTOSAR-A11_3_1-a-2 "Hidden friends permitted by A11-3-1 Permit #2"
2037 /// @brief Concatenate two strings
2038 ///
2039 /// @param lhs The first string to concatenate
2040 /// @param rhs The second string to concatenate
2041 /// @return inline_string holding the concatenation of the two strings.
2042 /// @pre @c lhs.size()+rhs.size()<=lhs.max_size() else @c ARENE_PRECONDITION violation.
2043 ARENE_NODISCARD friend constexpr auto operator+(inline_string const& lhs, string_view const rhs) noexcept
2044 -> inline_string {
2045 ARENE_PRECONDITION(lhs.size() + rhs.size() <= lhs.max_size());
2046 inline_string res{lhs};
2047 std::ignore = res.append(rhs);
2048 return res;
2049 }
2050 // parasoft-end-suppress AUTOSAR-A11_3_1-a-2
2051 // parasoft-end-suppress AUTOSAR-A0_1_3-a-2
2052
2053 // parasoft-begin-suppress AUTOSAR-A0_1_3-a-2 "False positive: This is a namespace scope function"
2054 // parasoft-begin-suppress AUTOSAR-A11_3_1-a-2 "Hidden friends permitted by A11-3-1 Permit #2"
2055 /// @brief Concatenate two strings
2056 ///
2057 /// @param lhs The first string to concatenate
2058 /// @param rhs The second string to concatenate
2059 /// @return inline_string holding the concatenation of the two strings.
2060 /// @pre @c lhs.size()+rhs.size()<=rhs.max_size() else @c ARENE_PRECONDITION violation.
2061 ARENE_NODISCARD friend constexpr auto operator+(string_view const lhs, inline_string const& rhs) noexcept
2062 -> inline_string {
2063 ARENE_PRECONDITION(lhs.size() + rhs.size() <= rhs.max_size());
2064 inline_string res{lhs};
2065 std::ignore = res.append(rhs);
2066 return res;
2067 }
2068 // parasoft-end-suppress AUTOSAR-A11_3_1-a-2
2069 // parasoft-end-suppress AUTOSAR-A0_1_3-a-2
2070
2071 private:
2072 /// @brief Tag-dispatch implementation helpers for @c inline_string::try_construct(first,last) .
2073 ///
2074 /// @tparam Itr The type of the iterator.
2075 /// @param first The start of the sequence to construct from.
2076 /// @param last The end of the sequence to construct from.
2077 /// @return optional<inline_string> If @c std::distance(first,last)>MaxLength a null optional, else an optional
2078 /// populated is if via @c inline_string{first,last} .
2079 template <typename Itr>
2080 static constexpr auto do_try_construct(std::random_access_iterator_tag, Itr first, Itr last) noexcept
2082 if (::arene::base::distance(first, last) > static_cast<difference_type>(MaxSize)) {
2083 return nullopt;
2084 }
2085 return {inline_string{first, last}};
2086 }
2087
2088 /// @brief Tag-dispatch implementation helpers for @c inline_string::try_construct(first,last) .
2089 ///
2090 /// @tparam Itr The type of the iterator.
2091 /// @param first The start of the sequence to construct from.
2092 /// @param last The end of the sequence to construct from.
2093 /// @return optional<inline_string> If @c std::distance(first,last)>MaxLength a null optional, else an optional
2094 /// populated is if via @c 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> {
2098 inline_string str;
2099 while ((str.size() < str.max_size()) && (first != last)) {
2100 str.push_back(*(first++));
2101 }
2102 if (first != last) {
2103 return nullopt;
2104 }
2105 return str;
2106 }
2107
2108 /// @brief Tag-dispatch implementation helpers for @c inline_string::insert(pos,first,last) .
2109 ///
2110 /// @tparam Itr The type of the iterator.
2111 /// @param pos The location to start the insert
2112 /// @param first The start of the sequence to insert.
2113 /// @param last The end of the sequence to insert.
2114 /// @return iterator An iterator to the beginning of the insertion.
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;
2120 }
2121 /// @brief Tag-dispatch implementation helpers for @c inline_string::insert(pos,first,last) .
2122 ///
2123 /// @tparam Itr The type of the iterator.
2124 /// @param pos The location to start the insert
2125 /// @param first The start of the sequence to insert.
2126 /// @param last The end of the sequence to insert.
2127 /// @return iterator An iterator to the beginning of the insertion.
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;
2132 ARENE_PRECONDITION(distance >= 0);
2133 auto const insertion_location = prepare_insert(static_cast<size_type>(offset), static_cast<size_type>(distance));
2134 std::ignore = ::arene::base::copy(first, last, insertion_location);
2135 return insertion_location;
2136 }
2137
2138 /// @brief Copy from the source span without bounds checking
2139 ///
2140 /// @param str the source data
2141 /// @post @c size()==str.size()
2142 /// @post The content of this string is equivalent to the content of @c str
2143 constexpr void copy_from_unchecked(string_view str) noexcept {
2144 std::ignore = arene::base::copy(str.begin(), str.end(), begin());
2145 set_null_terminator_to(str.size());
2146 }
2147
2148 /// @brief Copy from the source span with bounds checking.
2149 ///
2150 /// @param str the source data
2151 /// @pre @c str.size() is less than or equal to @c MaxLength else @c ARENE_PRECONDITION violation
2152 /// @post @c size()==str.size()
2153 /// @post The content of this string is equivalent to the content of @c str
2154 constexpr void copy_from(string_view str) noexcept {
2155 ARENE_PRECONDITION(str.size() <= MaxSize);
2156 copy_from_unchecked(str);
2157 }
2158
2159 /// @brief Copy from the source string
2160 ///
2161 /// @tparam SourceMaxLength The length of the source string. Must be less than or equal to @c MaxLength
2162 /// @param str the source data
2163 /// @post @c size()==str.size()
2164 /// @post The content of this string is equivalent to the content of @c str
2165 template <std::size_t SourceMaxLength, constraints<std::enable_if_t<SourceMaxLength <= MaxSize>> = nullptr>
2166 constexpr void copy_from(inline_string<SourceMaxLength> str) noexcept {
2167 copy_from_unchecked(string_view(str));
2168 }
2169
2170 /// @brief Copy from the source string
2171 ///
2172 /// @tparam SourceMaxLength The length of the source string. Must be greater than @c MaxLength
2173 /// @param str the source data
2174 /// @pre @c str.size() is less than or equal to @c MaxLength else @c ARENE_PRECONDITION violation
2175 /// @post @c size()==str.size()
2176 /// @post The content of this string is equivalent to the content of @c str
2177 template <std::size_t SourceMaxLength, constraints<std::enable_if_t<(SourceMaxLength > MaxSize)>> = nullptr>
2178 constexpr void copy_from(inline_string<SourceMaxLength> str) noexcept {
2179 copy_from(string_view(str));
2180 }
2181
2182 /// @brief Copy from the source NUL-terminated string
2183 ///
2184 /// @param str Pointer to the source string
2185 /// @pre @c str must not be a null pointer, else @c ARENE_PRECONDITION violation.
2186 /// @pre The length of @c str must be less than @c MaxLength , else @c ARENE_PRECONDITION violation.
2187 /// @pre @c str must point to a NUL-terminated string, else behavior is undefined.
2188 /// @post @c size() is the length of @c str
2189 /// @post The content of this string is equivalent to the content of @c str
2190 constexpr void copy_from(detail::raw_c_string str) noexcept {
2191 ARENE_PRECONDITION(str != nullptr);
2192 copy_from(string_view{str});
2193 }
2194
2195 /// @brief Copy from a pair of iterators
2196 ///
2197 /// @tparam Itr The type of the iterator.
2198 /// @param first The start of the sequence to insert.
2199 /// @param last The end of the sequence to insert.
2200 /// @pre @c std::distance(first,last)<=MaxSize else @c ARENE_PRECONDITION violation
2201 /// @post @c size() is the length of @c str
2202 /// @post The content of this string is equivalent to the content of @c str
2203 template <typename Itr>
2204 constexpr void copy_from(std::input_iterator_tag, Itr first, Itr last) noexcept {
2205 for (auto const chr : make_subrange(first, last)) {
2206 push_back(chr);
2207 }
2208 }
2209 /// @brief Copy from a pair of iterators
2210 ///
2211 /// @tparam Itr The type of the iterator.
2212 /// @param first The start of the sequence to insert.
2213 /// @param last The end of the sequence to insert.
2214 /// @pre @c std::distance(first,last)<=MaxSize else @c ARENE_PRECONDITION violation
2215 /// @post @c size() is the length of @c str
2216 /// @post The content of this string is equivalent to the content of @c str
2217 template <typename Itr>
2218 constexpr void copy_from(std::random_access_iterator_tag, Itr first, Itr last) noexcept {
2219 auto const source_length = ::arene::base::distance(first, last);
2220 ARENE_PRECONDITION(source_length >= 0);
2221 auto const usource_length = static_cast<size_type>(source_length);
2222 ARENE_PRECONDITION(usource_length <= max_size());
2223 std::ignore = ::arene::base::copy(first, last, begin());
2224 set_null_terminator_to(usource_length);
2225 }
2226
2227 /// @brief Prepare for an insert of the specified length at the specified position.
2228 ///
2229 /// Increases the length and moves the characters, so the @c insertion_length characters at @c pos can be
2230 /// overwritten.
2231 /// @param pos The position the insert will occur.
2232 /// @param insertion_length The length of the insertion.
2233 /// @return iterator An iterator to the location to perform the insertion.
2234 /// @pre @c pos<=size() else @c ARENE_PRECONDITION violation.
2235 /// @pre @c MaxLength-size()>=insertion_length else @c ARENE_PRECONDITION violation.
2236 /// @post @c size() is increased by @c insertion_length .
2237 /// @post The characters in the range @c [pos,insertion_length) are now located in the range
2238 /// @c [insertion_length,size())
2239 // NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
2240 constexpr auto prepare_insert(size_type pos, size_type insertion_length) noexcept -> iterator {
2241 ARENE_PRECONDITION(pos <= this->size());
2242 ARENE_PRECONDITION(max_size() - this->size() >= insertion_length);
2244 rbegin(),
2245 rbegin() + static_cast<std::ptrdiff_t>(this->size() - pos),
2246 rbegin() - static_cast<std::ptrdiff_t>(insertion_length)
2247 );
2248 set_null_terminator_to(this->size() + insertion_length);
2249 return begin() + static_cast<difference_type>(pos);
2250 }
2251
2252 /// @brief Prepare for a replacement of the specified length at the specified position with a new string of the
2253 /// specified replacement length.
2254 ///
2255 /// Increases or decreases the length and moves the characters, so the @c original_length characters at @c pos can
2256 /// be overwritten with @c replacement_length new characters.
2257 /// @param pos The position the insert will occur
2258 /// @param original_length The number of characters being replaced
2259 /// @param replacement_length The number of characters in the replacement
2260 /// @pre @c pos<=size() else @c ARENE_PRECONDITION violation.
2261 /// @pre @c size()-removal_length+replacement_length<=(MaxLength) else @c ARENE_PRECONDITION violation.
2262 // NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
2263 constexpr void prepare_replace(size_type pos, size_type original_length, size_type replacement_length) {
2264 ARENE_PRECONDITION(pos <= this->size());
2265 auto const removal_length = std::min(original_length, this->size() - pos);
2266 ARENE_PRECONDITION(this->size() - removal_length + replacement_length <= MaxSize);
2267 if (removal_length > replacement_length) {
2268 std::ignore = erase(pos + replacement_length, removal_length - replacement_length);
2269 } else {
2270 std::ignore = prepare_insert(pos + removal_length, replacement_length - removal_length);
2271 }
2272 }
2273
2274 /// @brief Sets the null terminator to the desired index.
2275 ///
2276 /// @param pos The index into buffer to place the null terminator.
2277 /// @post @c size()==pos
2278 /// @post @c buffer_[size()]=='\0'
2279 constexpr void set_null_terminator_to(size_type pos) {
2280 this->set_size(pos);
2281 buffer_[this->size()] = '\0';
2282 }
2283
2284 /// @brief The stored characters
2285 arene::base::array<detail::character, MaxSize + 1> buffer_{};
2286};
2287// parasoft-end-suppress AUTOSAR-A10_1_1-a-2
2288
2289template <std::size_t MaxLength>
2291
2292namespace inline_string_detail {
2293
2294/// @brief helper for @c is_inline_string_v
2295/// @tparam Type type to check
2296template <typename Type, typename = constraints<>>
2297extern constexpr bool is_inline_string_v = false;
2298
2299/// @brief helper for @c is_inline_string_v
2300/// @tparam Capacity capacity of the inline string
2301template <std::size_t Capacity>
2302extern constexpr bool is_inline_string_v<inline_string<Capacity>> = true;
2303
2304} // namespace inline_string_detail
2305
2306/// @brief Trait to query if a type is an @c inline_string.
2307/// @tparam Type The type to check.
2308///
2309/// @c true if @c Type is a cv-qualified instantiation of @c inline_string. Otherwise, @c false.
2310template <typename Type>
2311extern constexpr bool is_inline_string_v = inline_string_detail::is_inline_string_v<std::remove_cv_t<Type>>;
2312
2313/// @brief Trait to query if a type is an @c inline_string.
2314/// @tparam Type The type to check.
2315///
2316/// Inherits from @c std::true_type if @c Type is an
2317/// instantiation of @c inline_string, else @c std::false_type.
2318template <typename Type>
2319class is_inline_string : public std::integral_constant<bool, is_inline_string_v<Type>> {};
2320
2321/// @brief Trait to query if a type is an @c inline_string.
2322/// @tparam Type The type to check.
2323///
2324/// @c true if @c Type is a cv-qualified instantiation of @c inline_string. Otherwise, @c false.
2325template <typename Type>
2327
2328/// @brief Trait to query if a type is an @c inline_string.
2329/// @tparam Type The type to check.
2330///
2331/// Inherits from @c std::true_type if @c Type is an
2332/// instantiation of @c inline_string, else @c std::false_type.
2333template <typename Type>
2335
2336namespace inline_string_detail {
2337
2338/// @brief helper for constructing an @c inline_string
2339class make_inline_string_impl_fn {
2340 public:
2341 /// @brief Construct from a C-array of characters (e.g. a string literal)
2342 /// @tparam N the size of the source character array
2343 /// @param str The string to copy from
2344 /// @pre @c str must have a NUL terminator somewhere in it
2345 /// @post The content of this string compares equal to @c str
2346 /// @return @c str as an @c inline_string
2347 template <std::size_t N, constraints<std::enable_if_t<N != 0>> = nullptr>
2348 // NOLINTNEXTLINE(hicpp-avoid-c-arrays) allows use of string literals
2349 constexpr auto operator()(detail::character const (&str)[N]) const noexcept -> inline_string<N - 1U> {
2350 return inline_string<N - 1U>{str};
2351 }
2352};
2353
2354} // namespace inline_string_detail
2355
2356/// @brief helper for constructing an @c inline_string that deduces the capacity template parameter
2357// parasoft-begin-suppress AUTOSAR-M7_3_3-a "An unnamed namespace is used to create a per-TU reference to a global
2358// object used in multiple TUs."
2359// parasoft-begin-suppress CERT_CPP-DCL59-a "An unnamed namespace is used to create a per-TU reference to a global
2360// object used in multiple TUs."
2361ARENE_CPP14_INLINE_VARIABLE(inline_string_detail::make_inline_string_impl_fn, make_inline_string);
2362// parasoft-end-suppress AUTOSAR-M7_3_3-a
2363// parasoft-end-suppress CERT_CPP-DCL59-a
2364
2365} // namespace base
2366} // namespace arene
2367
2368#endif // INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_STRINGS_INLINE_STRING_HPP_
#define ARENE_CPP14_INLINE_VARIABLE(type, name)
Emulates C++17's inline variable declarations for function objects.
Definition cpp14_inline.hpp:69
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.