1209template<
class FULL_STRING_TYPE>
1213 typedef typename FULL_STRING_TYPE::size_type size_type;
1216 FULL_STRING_TYPE *d_string_p;
1219 size_type d_originalLength;
1276template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
1279 typename allocator_traits<ALLOCATOR>::size_type>
1280 ,
private BloombergLP::bslalg::ContainerBase<ALLOCATOR>
1287 typedef BloombergLP::bslmf::MovableRefUtil MoveUtil;
1291 typedef BloombergLP::bslma::AllocatorUtil AllocatorUtil;
1325 BloombergLP::bslmf::IsBitwiseMoveable,
1326 BloombergLP::bslmf::IsBitwiseMoveable<ALLOCATOR>::value);
1332 typedef BloombergLP::bslalg::ContainerBase<ALLOCATOR> ContainerBase;
1354 static void privateThrowLengthError(
bool maxLengthExceeded,
1355 const char *message);
1359 static void privateThrowOutOfRange(
bool outOfRange,
const char *message);
1370 CHAR_TYPE *privateAllocate(
size_type numChars);
1375 void privateDeallocate();
1384 void privateCopyFromOutOfPlaceBuffer(
const basic_string& original);
1392 basic_string& privateAppend(
const CHAR_TYPE *characterString,
1394 const char *message);
1401 CHAR_TYPE character,
1402 const char *message);
1412 const char *message,
1413 std::forward_iterator_tag);
1416 const char *message,
1417 std::forward_iterator_tag);
1422 template <
class INPUT_ITER>
1425 const char *message,
1426 std::input_iterator_tag);
1431 template <
class INPUT_ITER>
1434 const char *message,
1435 std::forward_iterator_tag);
1439 template<
class INPUT_ITER>
1442 const char *message);
1445 template <
class INPUT_ITER>
1449 const char *message,
1450 BloombergLP::bslmf::MatchArithmeticType,
1451 BloombergLP::bslmf::Nil);
1454 template <
class INPUT_ITER>
1458 const char *message,
1459 BloombergLP::bslmf::MatchAnyType,
1460 BloombergLP::bslmf::MatchAnyType);
1472 template<
class FIRST_TYPE,
class SECOND_TYPE>
1475 const char *message);
1484 void privateClear(
bool deallocateBufferFlag);
1505 template <
class INPUT_ITER>
1517 const CHAR_TYPE *characterString,
1533 const CHAR_TYPE *characterString,
1546 CHAR_TYPE character);
1549 template <
class INPUT_ITER>
1555 BloombergLP::bslmf::MatchArithmeticType ,
1556 BloombergLP::bslmf::Nil );
1559 template <
class INPUT_ITER>
1565 BloombergLP::bslmf::MatchAnyType ,
1566 BloombergLP::bslmf::MatchAnyType );
1570 template <
class INPUT_ITER>
1575 std::input_iterator_tag);
1580 template <
class INPUT_ITER>
1585 std::forward_iterator_tag);
1596 std::forward_iterator_tag);
1601 std::forward_iterator_tag);
1608 void privateReserveRaw(
size_type newCapacity);
1623 CHAR_TYPE *privateReserveRaw(
size_type *storage,
1640 template <
bool ALLOC_PROP>
1661 int privateCompareRaw(
size_type lhsPosition,
1663 const CHAR_TYPE *other,
1668 typename ALLOCATOR::value_type>::value));
1711 const ALLOCATOR& basicAllocator);
1728 const ALLOCATOR& basicAllocator);
1737 const ALLOCATOR& basicAllocator = ALLOCATOR());
1750 const ALLOCATOR& basicAllocator = ALLOCATOR());
1752#ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
1758 template <class = bsl::enable_if_t<bsl::IsStdAllocator<ALLOCATOR>::value>>
1761 const ALLOCATOR& basicAllocator = ALLOCATOR());
1772 const ALLOCATOR& basicAllocator = ALLOCATOR());
1774#ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
1779 template <class = bsl::enable_if_t<bsl::IsStdAllocator<ALLOCATOR>::value>>
1782 CHAR_TYPE character,
1783 const ALLOCATOR& basicAllocator = ALLOCATOR());
1793 template <
class INPUT_ITER>
1796 const ALLOCATOR& basicAllocator = ALLOCATOR());
1806 template <
class ALLOC2>
1808 const std::basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC2>& original,
1809 const ALLOCATOR& basicAllocator = ALLOCATOR());
1816 basic_string(
const BloombergLP::bslstl::StringRefData<CHAR_TYPE>& strRef,
1817 const ALLOCATOR& basicAllocator = ALLOCATOR());
1823 template <
class STRING_VIEW_LIKE_TYPE>
1825 const STRING_VIEW_LIKE_TYPE&
object
1834 template <
class STRING_VIEW_LIKE_TYPE>
1838 const ALLOCATOR& basicAllocator = ALLOCATOR()
1841#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
1847 const ALLOCATOR& basicAllocator =
1873 basic_string& operator=(BloombergLP::bslmf::MovableRef<basic_string> rhs)
1875 AllocatorTraits::propagate_on_container_move_assignment::value ||
1876 AllocatorTraits::is_always_equal::value);
1881 template <
class STRING_VIEW_LIKE_TYPE>
1883 operator=(
const STRING_VIEW_LIKE_TYPE& rhs);
1897 template <
class ALLOC2>
1899 const std::basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOC2>& rhs);
1901#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
1905 basic_string& operator=(std::initializer_list<CHAR_TYPE> values);
1914 void resize(
size_type newLength, CHAR_TYPE character);
1932 template <
class OPERATION>
1933 void resize_and_overwrite(
size_type newLength, OPERATION operation);
1939 void reserve(
size_type newCapacity = 0);
1946 void shrink_to_fit();
2014 template <class STRING_VIEW_LIKE_TYPE>
2016 operator+=(const STRING_VIEW_LIKE_TYPE& rhs);
2020 template <class ALLOC2>
2049 basic_string& append(const CHAR_TYPE *characterString);
2060 template <class STRING_VIEW_LIKE_TYPE>
2062 append(const STRING_VIEW_LIKE_TYPE& suffix);
2072 template <class STRING_VIEW_LIKE_TYPE>
2074 append(const STRING_VIEW_LIKE_TYPE& suffix,
2084 template <class INPUT_ITER>
2087#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
2091 basic_string& append(std::initializer_list<CHAR_TYPE> values);
2095 void push_back(CHAR_TYPE character);
2116 BloombergLP::bslmf::MovableRef<basic_string> replacement)
2135 basic_string& assign(
const CHAR_TYPE *characterString);
2148 template <
class STRING_VIEW_LIKE_TYPE>
2150 assign(
const STRING_VIEW_LIKE_TYPE& replacement);
2159 template <
class STRING_VIEW_LIKE_TYPE>
2161 assign(
const STRING_VIEW_LIKE_TYPE& replacement,
2167 template <
class ALLOC2>
2169 const std::basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOC2>&
string);
2183 template <
class INPUT_ITER>
2186#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
2191 basic_string& assign(std::initializer_list<CHAR_TYPE> values);
2219 const CHAR_TYPE *characterString,
2228 const CHAR_TYPE *characterString);
2236 CHAR_TYPE character);
2253 template <
class INPUT_ITER>
2266 CHAR_TYPE character);
2273 template <
class STRING_VIEW_LIKE_TYPE>
2275 insert(
size_type position,
const STRING_VIEW_LIKE_TYPE& other);
2287 template <
class STRING_VIEW_LIKE_TYPE>
2290 const STRING_VIEW_LIKE_TYPE& other,
2294#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
2304 std::initializer_list<CHAR_TYPE> values);
2375 const CHAR_TYPE *characterString,
2387 const CHAR_TYPE *characterString);
2398 CHAR_TYPE character);
2406 template <
class STRING_VIEW_LIKE_TYPE>
2410 const STRING_VIEW_LIKE_TYPE& replacement);
2423 template <
class STRING_VIEW_LIKE_TYPE>
2427 const STRING_VIEW_LIKE_TYPE& replacement,
2447 template <
class STRING_VIEW_LIKE_TYPE>
2451 const STRING_VIEW_LIKE_TYPE& replacement);
2462 const CHAR_TYPE *characterString,
2474 const CHAR_TYPE *characterString);
2485 CHAR_TYPE character);
2497 template <
class INPUT_ITER>
2500 INPUT_ITER stringFirst,
2501 INPUT_ITER stringLast);
2600 const CHAR_TYPE& front() const;
2606 const CHAR_TYPE& back() const;
2616 size_type copy(CHAR_TYPE *characterString,
2664 template <class STRING_VIEW_LIKE_TYPE>
2666 const STRING_VIEW_LIKE_TYPE& substring,
2678 size_type find(const CHAR_TYPE *substring,
2681 size_type find(const CHAR_TYPE *substring,
2717 template <class STRING_VIEW_LIKE_TYPE>
2719 const STRING_VIEW_LIKE_TYPE& substring,
2731 size_type rfind(const CHAR_TYPE *characterString,
2734 size_type rfind(const CHAR_TYPE *characterString,
2768 template <class STRING_VIEW_LIKE_TYPE>
2770 const STRING_VIEW_LIKE_TYPE& characterString,
2782 size_type find_first_of(const CHAR_TYPE *characterString,
2785 size_type find_first_of(const CHAR_TYPE *characterString,
2792 size_type find_first_of(CHAR_TYPE character,
2820 template <class STRING_VIEW_LIKE_TYPE>
2822 const STRING_VIEW_LIKE_TYPE& characterString,
2834 size_type find_last_of(const CHAR_TYPE *characterString,
2837 size_type find_last_of(const CHAR_TYPE *characterString,
2844 size_type find_last_of(CHAR_TYPE character,
2872 template <class STRING_VIEW_LIKE_TYPE>
2874 const STRING_VIEW_LIKE_TYPE& characterString,
2886 size_type find_first_not_of(const CHAR_TYPE *characterString,
2889 size_type find_first_not_of(const CHAR_TYPE *characterString,
2897 size_type find_first_not_of(CHAR_TYPE character,
2925 template <class STRING_VIEW_LIKE_TYPE>
2927 const STRING_VIEW_LIKE_TYPE& characterString,
2939 size_type find_last_not_of(const CHAR_TYPE *characterString,
2942 size_type find_last_not_of(const CHAR_TYPE *characterString,
2950 size_type find_last_not_of(CHAR_TYPE character,
2974 bool starts_with(const CHAR_TYPE *characterString) const;
2997 bool ends_with(const CHAR_TYPE *characterString) const;
3058 int compare(const CHAR_TYPE *other) const;
3072 const CHAR_TYPE *other,
3088 const CHAR_TYPE *other) const;
3106 template <class STRING_VIEW_LIKE_TYPE>
3108 const STRING_VIEW_LIKE_TYPE& other
3121 template <class STRING_VIEW_LIKE_TYPE>
3125 const STRING_VIEW_LIKE_TYPE& other
3143 template <class STRING_VIEW_LIKE_TYPE>
3147 const STRING_VIEW_LIKE_TYPE& other,
3160 template <class ALLOC2>
3164 std::basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC2> result;
3177#ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
3190 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC, ALLOCATOR>>
3192basic_string(basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>, ALLOC)
3193-> basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>;
3203 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
3205basic_string(
const CHAR_TYPE *, ALLOC *)
3206-> basic_string<CHAR_TYPE>;
3217 class = bsl::enable_if_t<
3218 bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>,
3219 class = bsl::enable_if_t<!bsl::is_pointer_v<SZ>>
3223basic_string(
const CHAR_TYPE *, SZ, ALLOC *)
3224-> basic_string<CHAR_TYPE>;
3235 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
3237basic_string(SZ, CHAR_TYPE, ALLOC *)
3238-> basic_string<CHAR_TYPE>;
3250 class SZ =
typename allocator_traits<ALLOCATOR>::size_type,
3251 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, ALLOCATOR>>
3253basic_string(basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>, SZ, SZ, ALLOC *)
3254-> basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>;
3264 typename BloombergLP::bslstl::IteratorUtil::IterVal_t<INPUT_ITER>,
3266 class = bsl::enable_if_t<bsl::IsStdAllocator_v<ALLOCATOR>>
3268basic_string(INPUT_ITER, INPUT_ITER, ALLOCATOR = ALLOCATOR())
3269 -> basic_string<CHAR_TYPE, char_traits<CHAR_TYPE>, ALLOCATOR>;
3278 typename BloombergLP::bslstl::IteratorUtil::IterVal_t<INPUT_ITER>,
3281 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
3283basic_string(INPUT_ITER, INPUT_ITER, ALLOC *)
3284 -> basic_string<CHAR_TYPE>;
3295 class ALLOCATOR = allocator<CHAR_TYPE>,
3296 class = bsl::enable_if_t<bsl::IsStdAllocator_v<ALLOCATOR>>
3298basic_string(basic_string_view<CHAR_TYPE, CHAR_TRAITS>,
3299 ALLOCATOR = ALLOCATOR())
3300 -> basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>;
3312 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
3314basic_string(basic_string_view<CHAR_TYPE, CHAR_TRAITS>, ALLOC *)
3315 -> basic_string<CHAR_TYPE, CHAR_TRAITS>;
3325 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
3327basic_string(std::initializer_list<CHAR_TYPE>, ALLOC *)
3328-> basic_string<CHAR_TYPE>;
3333template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
3337template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC1,
class ALLOC2>
3340 const std::basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC2>& rhs)
3347template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
3349 const CHAR_TYPE *rhs);
3351#ifdef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
3353template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
3354String_ComparisonCategoryType<CHAR_TRAITS>
3362template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
3363String_ComparisonCategoryType<CHAR_TRAITS>
3365 const CHAR_TYPE *rhs);
3366template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC1,
class ALLOC2>
3367String_ComparisonCategoryType<CHAR_TRAITS>
3369 const std::basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC2>& rhs)
3378template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC1,
class ALLOC2>
3380operator==(
const std::basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC1>& lhs,
3383template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
3384bool operator==(
const CHAR_TYPE *lhs,
3391template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
3395template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC1,
class ALLOC2>
3397operator!=(
const std::basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC1>& lhs,
3400template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC1,
class ALLOC2>
3403 const std::basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC2>& rhs)
3406template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
3407bool operator!=(
const CHAR_TYPE *lhs,
3409template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
3411 const CHAR_TYPE *rhs);
3416template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
3420template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC1,
class ALLOC2>
3422operator<(
const std::basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC1>& lhs,
3425template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC1,
class ALLOC2>
3428 const std::basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC2>& rhs)
3430template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
3432bool operator<(
const CHAR_TYPE *lhs,
3434template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
3436 const CHAR_TYPE *rhs);
3438template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
3442template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC1,
class ALLOC2>
3444operator>(
const std::basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC1>& lhs,
3447template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC1,
class ALLOC2>
3450 const std::basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC2>& rhs)
3456template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
3457bool operator>(
const CHAR_TYPE *lhs,
3459template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
3461 const CHAR_TYPE *rhs);
3466template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
3470template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC1,
class ALLOC2>
3472operator<=(
const std::basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC1>& lhs,
3475template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC1,
class ALLOC2>
3478 const std::basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC2>& rhs)
3481template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
3482bool operator<=(
const CHAR_TYPE *lhs,
3484template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
3486 const CHAR_TYPE *rhs);
3491template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
3495template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC1,
class ALLOC2>
3497operator>=(
const std::basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC1>& lhs,
3500template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC1,
class ALLOC2>
3503 const std::basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC2>& rhs)
3506template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
3507bool operator>=(
const CHAR_TYPE *lhs,
3509template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
3511 const CHAR_TYPE *rhs);
3520template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
3524#ifdef BSLSTL_STRING_SUPPORT_RVALUE_ADDITION_OPERATORS
3525template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
3529template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
3533template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
3538template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC1,
class ALLOC2>
3540operator+(
const std::basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC1>& lhs,
3542#ifdef BSLSTL_STRING_SUPPORT_RVALUE_ADDITION_OPERATORS
3543template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC1,
class ALLOC2>
3545operator+(
const std::basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC1>& lhs,
3548template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC1,
class ALLOC2>
3551 const std::basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC2>& rhs);
3552#ifdef BSLSTL_STRING_SUPPORT_RVALUE_ADDITION_OPERATORS
3553template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC1,
class ALLOC2>
3556 const std::basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC2>& rhs);
3558template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
3562#ifdef BSLSTL_STRING_SUPPORT_RVALUE_ADDITION_OPERATORS
3563template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
3568template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
3572#ifdef BSLSTL_STRING_SUPPORT_RVALUE_ADDITION_OPERATORS
3573template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
3578template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
3581 const CHAR_TYPE *rhs);
3582#ifdef BSLSTL_STRING_SUPPORT_RVALUE_ADDITION_OPERATORS
3583template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
3586 const CHAR_TYPE *rhs);
3588template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
3592#ifdef BSLSTL_STRING_SUPPORT_RVALUE_ADDITION_OPERATORS
3593template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
3605template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
3606std::basic_ostream<CHAR_TYPE, CHAR_TRAITS>&
3607operator<<(std::basic_ostream<CHAR_TYPE, CHAR_TRAITS>& os,
3619template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
3620std::basic_istream<CHAR_TYPE, CHAR_TRAITS>&
3624#if defined (BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY) && \
3625 defined (BSLS_COMPILERFEATURES_SUPPORT_INLINE_NAMESPACE)
3626inline namespace literals {
3627inline namespace string_literals {
3645 string operator ""_s(
const char *characterString, std::size_t length);
3646wstring operator ""_s(
const wchar_t *characterString, std::size_t length);
3648#if !defined(BSLS_PLATFORM_OS_SOLARIS) || \
3649 (defined(BSLS_PLATFORM_CMP_GNU) && BSLS_PLATFORM_CMP_VERSION >= 800000)
3663 string operator ""_S(
const char *characterString, std::size_t length);
3664wstring operator ""_S(
const wchar_t *characterString, std::size_t length);
3687template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
3702template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
3703std::basic_istream<CHAR_TYPE, CHAR_TRAITS>&
3704getline(std::basic_istream<CHAR_TYPE, CHAR_TRAITS>& is,
3717template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
3718std::basic_istream<CHAR_TYPE, CHAR_TRAITS>&
3719getline(std::basic_istream<CHAR_TYPE, CHAR_TRAITS>& is,
3722int stoi(
const string& str, std::size_t *pos = 0,
int base = 10);
3724long stol(
const string& str, std::size_t *pos = 0,
int base = 10);
3726unsigned long stoul(
const string& str, std::size_t *pos = 0,
int base = 10);
3727unsigned long stoul(
const wstring& str, std::size_t *pos = 0,
int base = 10);
3728long long stoll(
const string& str, std::size_t *pos = 0,
int base = 10);
3732 std::size_t *pos = 0,
3735 std::size_t *pos = 0,
3738float stof(
const string& str, std::size_t *pos =0);
3740double stod(
const string& str, std::size_t *pos =0);
3762long double stold(
const string& str, std::size_t *pos =0);
3871template <
class CHAR_TYPE,
3874 class OTHER_CHAR_TYPE>
3877 const OTHER_CHAR_TYPE& c);
3882template <
class CHAR_TYPE,
3885 class UNARY_PREDICATE>
3888 const UNARY_PREDICATE& pred);
3910template <
class HASHALG,
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
3915template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
3927template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
3929 : ::BloombergLP::bslh::Hash<>
3934 std::size_t operator()(
3940 std::size_t operator()(
const CHAR_TYPE *input)
const;
3943#if defined(BSLS_PLATFORM_CMP_SUN) && BSLS_PLATFORM_CMP_VERSION < 0x5130
3951struct hash<
string> : ::BloombergLP::bslh::Hash<>
3956 std::size_t operator()(
const string& input)
const;
3961 std::size_t operator()(
const char *input)
const;
3965struct hash<
wstring> : ::BloombergLP::bslh::Hash<>
3970 std::size_t operator()(
const wstring& input)
const;
3975 std::size_t operator()(
const wchar_t *input)
const;
3994template <
class HASHALG,
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
3998 const std::basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>& input);
4014template <
class CHAR_TYPE,
class SIZE_TYPE>
4017 SIZE_TYPE oldCapacity,
4031 SIZE_TYPE newCapacity = oldCapacity + (oldCapacity >> 1);
4033 if (newLength > newCapacity) {
4034 newCapacity = newLength;
4037 if (newCapacity < oldCapacity || newCapacity > maxSize) {
4038 newCapacity = maxSize;
4045template <
class CHAR_TYPE,
class SIZE_TYPE>
4050, d_capacity(this->SHORT_BUFFER_CAPACITY)
4054template <
class CHAR_TYPE,
class SIZE_TYPE>
4060, d_capacity(capacity <= static_cast<SIZE_TYPE>(this->SHORT_BUFFER_CAPACITY)
4061 ? static_cast<SIZE_TYPE>(this->SHORT_BUFFER_CAPACITY)
4067template <
class CHAR_TYPE,
class SIZE_TYPE>
4072 BloombergLP::bslalg::ScalarPrimitives::swap(d_length, other.
d_length);
4073 BloombergLP::bslalg::ScalarPrimitives::swap(d_capacity,
4075 BloombergLP::bslalg::ScalarPrimitives::swap(d_start_p,
4081 BloombergLP::bslalg::ScalarPrimitives::swap(*
this, other);
4086template <
class CHAR_TYPE,
class SIZE_TYPE>
4092 d_capacity = this->SHORT_BUFFER_CAPACITY;
4096template <
class CHAR_TYPE,
class SIZE_TYPE>
4100 return isShortString()
4101 ?
reinterpret_cast<CHAR_TYPE *
>((
void *)d_short.buffer())
4106template <
class CHAR_TYPE,
class SIZE_TYPE>
4111#ifdef BSLS_PLATFORM_PRAGMA_GCC_DIAGNOSTIC_GCC
4112#pragma GCC diagnostic push
4113#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
4115 return d_capacity == this->SHORT_BUFFER_CAPACITY;
4117#ifdef BSLS_PLATFORM_PRAGMA_GCC_DIAGNOSTIC_GCC
4118#pragma GCC diagnostic pop
4122template <
class CHAR_TYPE,
class SIZE_TYPE>
4126 return isShortString()
4127 ?
reinterpret_cast<const CHAR_TYPE *
>((
const void *)d_short.buffer())
4136template <
class FULL_STRING_TYPE>
4138 FULL_STRING_TYPE *stringPtr)
4139: d_string_p(stringPtr)
4140, d_originalLength(stringPtr->d_length)
4142 d_string_p->d_length = 0;
4145template <
class FULL_STRING_TYPE>
4149 d_string_p->d_length = d_originalLength;
4154template <
class FULL_STRING_TYPE>
4165template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
4170template<
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
4174 bool maxLengthExceeded,
4175 const char *message)
4179 BloombergLP::bslstl::StdExceptUtil::throwLengthError(message);
4183template<
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
4186basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>::privateThrowOutOfRange(
4188 const char *message)
4192 BloombergLP::bslstl::StdExceptUtil::throwOutOfRange(message);
4197template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
4200basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>::privateAllocate(
4203 return AllocatorUtil::allocateObject<CHAR_TYPE>(this->allocatorRef(),
4207template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
4209void basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>::privateDeallocate()
4211 if (!this->isShortString()) {
4212 AllocatorUtil::deallocateObject(this->allocatorRef(),
4213 this->d_start_p, this->d_capacity + 1);
4217template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
4220basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>::privateCopyFromOutOfPlaceBuffer(
4221 const basic_string& original)
4230 static_cast<Imp &
>(*this) = Imp(original.length(), original.length());
4232 if (!this->isShortString()) {
4233 this->d_start_p = privateAllocate(this->d_capacity);
4236 CHAR_TRAITS::copy(this->dataPtr(), original.data(), this->d_length + 1);
4239template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
4240basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>&
4241basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>::privateAppend(
4242 const CHAR_TYPE *characterString,
4244 const char *message)
4246 privateThrowLengthError(numChars > max_size() - length(), message);
4248 size_type newLength = this->d_length + numChars;
4249 size_type newStorage = this->d_capacity;
4250 CHAR_TYPE *newBuffer = privateReserveRaw(&newStorage,
4255 CHAR_TRAITS::copy(newBuffer + this->d_length,
4258 CHAR_TRAITS::assign(*(newBuffer + newLength), CHAR_TYPE());
4260 privateDeallocate();
4262 this->d_start_p = newBuffer;
4263 this->d_capacity = newStorage;
4266 CHAR_TRAITS::move(this->dataPtr() + length(),
4269 CHAR_TRAITS::assign(*(this->dataPtr() + newLength), CHAR_TYPE());
4272 this->d_length = newLength;
4276template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
4277basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>&
4278basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>::privateAppend(
4280 CHAR_TYPE character,
4281 const char *message)
4283 privateThrowLengthError(numChars > max_size() - length(), message);
4285 size_type newLength = this->d_length + numChars;
4286 privateReserveRaw(newLength);
4287 CHAR_TRAITS::assign(this->dataPtr() + this->d_length, numChars, character);
4288 this->d_length = newLength;
4289 CHAR_TRAITS::assign(*(this->dataPtr() + newLength), CHAR_TYPE());
4293template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
4295basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>&
4296basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>::privateAppend(
4299 const char *message,
4300 std::forward_iterator_tag)
4304 return privateAppend(const_iterator(first),
4305 const_iterator(last),
4307 std::forward_iterator_tag());
4310template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
4312basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>&
4313basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>::privateAppend(
4314 const_iterator first,
4315 const_iterator last,
4316 const char *message,
4317 std::forward_iterator_tag)
4320 return privateAppend(&*first, last - first, message);
4323template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
4324template <
class INPUT_ITER>
4326basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>&
4330 const char *message,
4331 std::input_iterator_tag)
4334 for (; first != last; ++first) {
4337 if (length() == 0 && capacity() <= temp.
capacity()) {
4338 quickSwapRetainAllocators(temp);
4343 CHAR_TRAITS::assign(*(temp.dataPtr()), CHAR_TYPE());
4346 return privateAppend(temp.
data(), temp.
length(), message);
4349template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
4350template <
class INPUT_ITER>
4356 const char *message,
4357 std::forward_iterator_tag)
4359 size_type numChars = bsl::distance(first, last);
4360 privateThrowLengthError(numChars > max_size() - length(), message);
4362 size_type newLength = this->d_length + numChars;
4363 size_type newStorage = this->d_capacity;
4364 CHAR_TYPE *newBuffer = privateReserveRaw(&newStorage,
4369 for (
size_type pos = this->d_length; first != last; ++first, ++pos) {
4370 CHAR_TRAITS::assign(*(newBuffer + pos), *first);
4373 privateDeallocate();
4375 this->d_start_p = newBuffer;
4376 this->d_capacity = newStorage;
4379 for (
size_type pos = this->d_length; first != last; ++first, ++pos) {
4380 CHAR_TRAITS::assign(*(this->dataPtr() + pos), *first);
4384 CHAR_TRAITS::assign(*(this->dataPtr() + newLength), CHAR_TYPE());
4385 this->d_length = newLength;
4389template<
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
4390template<
class INPUT_ITER>
4396 const char *message)
4398 return privateAppendDispatch(first,
4402 BloombergLP::bslmf::Nil());
4405template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
4406template <
class INPUT_ITER>
4412 const char *message,
4413 BloombergLP::bslmf::MatchArithmeticType,
4414 BloombergLP::bslmf::Nil )
4416 return privateAppend((
size_type)first, (CHAR_TYPE)last, message);
4419template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
4420template <
class INPUT_ITER>
4426 const char *message,
4427 BloombergLP::bslmf::MatchAnyType,
4428 BloombergLP::bslmf::MatchAnyType )
4430 typename iterator_traits<INPUT_ITER>::iterator_category tag;
4431 return privateAppend(first, last, message, tag);
4434template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
4435template <
class FIRST_TYPE,
class SECOND_TYPE>
4441 const char *message)
4445 privateAppend(first, second, message);
4452template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
4457 return *
static_cast<Imp *
>(
this);
4460template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
4461void basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>::privateClear(
4462 bool deallocateBufferFlag)
4464 if (deallocateBufferFlag) {
4465 privateDeallocate();
4466 this->resetFields();
4472 CHAR_TRAITS::assign(*
begin(), CHAR_TYPE());
4475template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
4477void basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>::privateInsertDispatch(
4478 const_iterator position,
4484 privateInsertDispatch(position,
4485 const_iterator(first),
4486 const_iterator(last));
4489template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
4490void basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>::privateInsertDispatch(
4491 const_iterator position,
4492 const_iterator first,
4493 const_iterator last)
4497 size_type pos = position -
cbegin();
4498 privateThrowOutOfRange(
4500 "string<...>::insert<Iter>(pos,i,j): invalid position");
4502 size_type numChars = last - first;
4503 privateThrowLengthError(
4504 numChars > max_size() - length(),
4505 "string<...>::insert<Iter>(pos,i,j): string too long");
4507 privateInsertRaw(pos, &*first, numChars);
4510template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
4511template <
class INPUT_ITER>
4513void basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>::privateInsertDispatch(
4514 const_iterator position,
4518 size_type pos = position -
cbegin();
4519 privateReplaceDispatch(pos,
4524 BloombergLP::bslmf::Nil());
4527template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
4528basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>&
4529basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>::privateInsertRaw(
4530 size_type outPosition,
4531 const CHAR_TYPE *characterString,
4538 size_type newLength = this->d_length + numChars;
4539 size_type newStorage = this->d_capacity;
4540 CHAR_TYPE *newBuffer = privateReserveRaw(&newStorage,
4548 const CHAR_TYPE *tail = this->dataPtr() + outPosition;
4549 size_type tailLen = this->d_length - outPosition;
4551 CHAR_TRAITS::copy(newBuffer + outPosition, characterString, numChars);
4552 CHAR_TRAITS::copy(newBuffer + outPosition + numChars, tail, tailLen);
4553 CHAR_TRAITS::assign(*(newBuffer + newLength), CHAR_TYPE());
4555 privateDeallocate();
4557 this->d_start_p = newBuffer;
4558 this->d_capacity = newStorage;
4568 const CHAR_TYPE *first = characterString;
4569 const CHAR_TYPE *last = characterString + numChars;
4570 CHAR_TYPE *tail = this->dataPtr() + outPosition;
4571 size_type tailLen = this->d_length - outPosition;
4572 const CHAR_TYPE *shifted = (tail < first && last <= tail + tailLen)
4576 CHAR_TRAITS::move(tail + numChars, tail, tailLen);
4577 CHAR_TRAITS::move(tail, shifted, numChars);
4578 CHAR_TRAITS::assign(*(this->dataPtr() + newLength), CHAR_TYPE());
4581 this->d_length = newLength;
4585template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
4586basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>&
4587basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>::privateReplaceRaw(
4588 size_type outPosition,
4589 size_type outNumChars,
4590 const CHAR_TYPE *characterString,
4599 const difference_type displacement =
4600 static_cast<difference_type
>(numChars - outNumChars);
4602 size_type newLength = this->d_length + displacement;
4603 size_type newStorage = this->d_capacity;
4604 CHAR_TYPE *newBuffer = privateReserveRaw(&newStorage,
4608 const CHAR_TYPE *tail = this->dataPtr() + outPosition + outNumChars;
4609 size_type tailLen = this->d_length - outPosition - outNumChars;
4615 CHAR_TRAITS::copy(newBuffer + outPosition, characterString, numChars);
4616 CHAR_TRAITS::copy(newBuffer + outPosition + numChars, tail, tailLen);
4617 CHAR_TRAITS::assign(*(newBuffer + newLength), CHAR_TYPE());
4619 privateDeallocate();
4621 this->d_start_p = newBuffer;
4622 this->d_capacity = newStorage;
4623 this->d_length = newLength;
4631 CHAR_TYPE *dest = this->dataPtr() + outPosition;
4632 const CHAR_TYPE *first = characterString;
4633 const CHAR_TYPE *last = characterString + numChars;
4635 if (tail < last && last <= tail + tailLen) {
4643 size_type prefix = tail - first, suffix = last - tail;
4644 if (outNumChars < numChars) {
4645 CHAR_TRAITS::move(dest + numChars, tail, tailLen);
4646 CHAR_TRAITS::move(dest, first, prefix);
4649 CHAR_TRAITS::move(dest, first, prefix);
4650 CHAR_TRAITS::move(dest + numChars, tail, tailLen);
4652 CHAR_TRAITS::move(dest + prefix,
4653 last - suffix + displacement,
4660 CHAR_TRAITS::move(dest + numChars, tail, tailLen);
4661 CHAR_TRAITS::copy(dest, first + displacement, numChars);
4667 if (outNumChars < numChars) {
4668 CHAR_TRAITS::move(dest + numChars, tail, tailLen);
4669 CHAR_TRAITS::move(dest, characterString, numChars);
4672 CHAR_TRAITS::move(dest, characterString, numChars);
4673 CHAR_TRAITS::move(dest + numChars, tail, tailLen);
4676 CHAR_TRAITS::assign(*(this->dataPtr() + newLength), CHAR_TYPE());
4677 this->d_length = newLength;
4681template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
4682basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>&
4683basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>::privateReplaceRaw(
4684 size_type outPosition,
4685 size_type outNumChars,
4687 CHAR_TYPE character)
4694 size_type newLength = this->d_length - outNumChars + numChars;
4695 size_type newStorage = this->d_capacity;
4696 CHAR_TYPE *newBuffer = privateReserveRaw(&newStorage,
4700 const CHAR_TYPE *tail = this->dataPtr() + outPosition + outNumChars;
4701 size_type tailLen = this->d_length - outPosition - outNumChars;
4704 CHAR_TYPE *dest = newBuffer + outPosition;
4706 CHAR_TRAITS::assign(dest, numChars, character);
4707 CHAR_TRAITS::copy(dest + numChars, tail, tailLen);
4708 CHAR_TRAITS::assign(*(newBuffer + newLength), CHAR_TYPE());
4710 privateDeallocate();
4712 this->d_start_p = newBuffer;
4713 this->d_capacity = newStorage;
4716 CHAR_TYPE *dest = this->dataPtr() + outPosition;
4718 CHAR_TRAITS::move(dest + numChars, tail, tailLen);
4719 CHAR_TRAITS::assign(dest, numChars, character);
4720 CHAR_TRAITS::assign(*(this->dataPtr() + newLength), CHAR_TYPE());
4723 this->d_length = newLength;
4727template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
4728template <
class INPUT_ITER>
4730basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>&
4736 BloombergLP::bslmf::MatchArithmeticType ,
4737 BloombergLP::bslmf::Nil )
4739 return replace(position, numChars, (
size_type)first, (CHAR_TYPE)last);
4742template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
4743template <
class INPUT_ITER>
4751 BloombergLP::bslmf::MatchAnyType ,
4752 BloombergLP::bslmf::MatchAnyType )
4754 typename iterator_traits<INPUT_ITER>::iterator_category tag;
4755 return privateReplace(position, numChars, first, last, tag);
4758template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
4759template <
class INPUT_ITER>
4766 std::input_iterator_tag)
4768 privateThrowOutOfRange(
4769 length() < outPosition,
4770 "string<...>::replace<InputIter>(pos,n,i,j): invalid position");
4773 for (; first != last; ++first) {
4776 if (outPosition == 0 && length() <= outNumChars) {
4779 temp.privateReserveRaw(capacity());
4780 quickSwapRetainAllocators(temp);
4783 return privateReplaceRaw(outPosition,
4789template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
4790template <
class INPUT_ITER>
4797 std::forward_iterator_tag)
4799 privateThrowOutOfRange(
4800 length() < outPosition,
4801 "string<...>::replace<Iter>(pos,n,i,j): invalid position");
4803 size_type numChars = bsl::distance(first, last);
4804 privateThrowLengthError(
4805 max_size() - (length() - outPosition) < numChars,
4806 "string<...>::replace<Iter>(pos,n,i,j): string too long");
4813 for (
size_type pos = 0; pos != numChars; ++first, ++pos) {
4817 return privateReplaceRaw(outPosition,
4823template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
4828 const_iterator first,
4829 const_iterator last,
4830 std::forward_iterator_tag)
4834 privateThrowOutOfRange(
4835 length() < position,
4836 "string<...>::replace<Iter>(pos,n,i,j): invalid position");
4838 size_type numNewChars = bsl::distance(first, last);
4839 privateThrowLengthError(
4840 max_size() - (length() - position) < numNewChars,
4841 "string<...>::replace<Iter>(pos,n,i,j): string too long");
4843 return privateReplaceRaw(position, numChars, &*first, numNewChars);
4846template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
4848basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>&
4849basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>::privateReplace(
4854 std::forward_iterator_tag)
4858 return privateReplace(position,
4860 const_iterator(first),
4861 const_iterator(last),
4862 std::forward_iterator_tag());
4865template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
4866void basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>::privateReserveRaw(
4867 size_type newCapacity)
4871 if (this->d_capacity < newCapacity) {
4872 size_type newStorage = this->computeNewCapacity(newCapacity,
4875 CHAR_TYPE *newBuffer = privateAllocate(newStorage);
4877 CHAR_TRAITS::copy(newBuffer, this->dataPtr(), this->d_length + 1);
4879 privateDeallocate();
4881 this->d_start_p = newBuffer;
4882 this->d_capacity = newStorage;
4886template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
4888basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>::privateReserveRaw(
4890 size_type newCapacity,
4897 if (*storage >= newCapacity) {
4901 *storage = this->computeNewCapacity(newCapacity,
4905 CHAR_TYPE *newBuffer = privateAllocate(*storage);
4907 CHAR_TRAITS::copy(newBuffer, this->dataPtr(), numChars);
4911template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
4912basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>&
4913basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>::privateResizeRaw(
4914 size_type newLength,
4915 CHAR_TYPE character)
4919 privateReserveRaw(newLength);
4921 if (newLength > this->d_length) {
4922 CHAR_TRAITS::assign(this->dataPtr() + this->d_length,
4923 newLength - this->d_length,
4926 this->d_length = newLength;
4927 CHAR_TRAITS::assign(*(this->dataPtr() + this->d_length), CHAR_TYPE());
4931template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
4932template <
bool ALLOC_PROP>
4934void basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>::
4935quickSwapExchangeAllocators(basic_string& other,
4938 privateBase().swap(other.privateBase());
4939 AllocatorUtil::swap(&this->allocatorRef(), &other.allocatorRef(),
4943template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
4945void basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>::
4946 quickSwapRetainAllocators(basic_string& other)
4948 privateBase().swap(other.privateBase());
4952template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
4953int basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>::privateCompareRaw(
4954 size_type lhsPosition,
4955 size_type lhsNumChars,
4956 const CHAR_TYPE *other,
4957 size_type otherNumChars)
const
4964 size_type numChars = lhsNumChars < otherNumChars ? lhsNumChars
4966 int cmpResult = CHAR_TRAITS::compare(this->dataPtr() + lhsPosition,
4972 if (lhsNumChars < otherNumChars) {
4975 if (lhsNumChars > otherNumChars) {
4985template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
4992 CHAR_TRAITS::assign(*
begin(), CHAR_TYPE());
4995template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
4998 const ALLOCATOR& basicAllocator)
5001, ContainerBase(basicAllocator)
5003 CHAR_TRAITS::assign(*
begin(), CHAR_TYPE());
5006template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5011, ContainerBase(
AllocatorTraits::select_on_container_copy_construction(
5012 original.get_allocator()))
5018 privateCopyFromOutOfPlaceBuffer(original);
5022template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5026 const ALLOCATOR& basicAllocator)
5028, ContainerBase(basicAllocator)
5034 privateCopyFromOutOfPlaceBuffer(original);
5038template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5041 BloombergLP::bslmf::MovableRef<basic_string> original)
5044, ContainerBase(MoveUtil::access(original).get_allocator())
5046 if (!this->isShortString()) {
5047 basic_string& originalRef = MoveUtil::access(original);
5048 originalRef.resetFields();
5052template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5055 BloombergLP::bslmf::MovableRef<basic_string> original,
5056 const ALLOCATOR& basicAllocator)
5058, ContainerBase(basicAllocator)
5061 basic_string& originalRef = MoveUtil::access(original);
5064 originalRef.resetFields();
5067 privateCopyFromOutOfPlaceBuffer(originalRef);
5072template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5077 const ALLOCATOR& basicAllocator)
5079, ContainerBase(basicAllocator)
5084template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5090 const ALLOCATOR& basicAllocator)
5092, ContainerBase(basicAllocator)
5094 assign(original, position, numChars);
5097template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5098#ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
5103 const CHAR_TYPE *characterString,
5104 const ALLOCATOR& basicAllocator)
5106, ContainerBase(basicAllocator)
5113template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5116 const CHAR_TYPE *characterString,
5118 const ALLOCATOR& basicAllocator)
5120, ContainerBase(basicAllocator)
5124 assign(characterString, numChars);
5127template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5128#ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
5134 CHAR_TYPE character,
5135 const ALLOCATOR& basicAllocator)
5137, ContainerBase(basicAllocator)
5139 assign(numChars, character);
5142template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5143template <
class INPUT_ITER>
5148 const ALLOCATOR& basicAllocator)
5150, ContainerBase(basicAllocator)
5155template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5156template <
class ALLOC2>
5159 const std::basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC2>& original,
5160 const ALLOCATOR& basicAllocator)
5162, ContainerBase(basicAllocator)
5164 this->
assign(original.data(), original.length());
5167template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5170 const BloombergLP::bslstl::StringRefData<CHAR_TYPE>& strRef,
5171 const ALLOCATOR& basicAllocator)
5173, ContainerBase(basicAllocator)
5175 assign(strRef.data(), strRef.length());
5178template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5179template <
class STRING_VIEW_LIKE_TYPE>
5182 const STRING_VIEW_LIKE_TYPE&
object
5185, ContainerBase(basicAllocator)
5191template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5192template <
class STRING_VIEW_LIKE_TYPE>
5195 const STRING_VIEW_LIKE_TYPE&
object,
5198 const ALLOCATOR& basicAllocator
5201, ContainerBase(basicAllocator)
5204 privateThrowOutOfRange(
5205 position > strView.
length(),
5206 "string<...>::assign(const string_view&,pos,n): invalid position");
5208 if (numChars > strView.
length() - position) {
5209 numChars = strView.
length() - position;
5215#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
5216template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5219 std::initializer_list<CHAR_TYPE> values,
5220 const ALLOCATOR& basicAllocator)
5222, ContainerBase(basicAllocator)
5224 append(values.begin(), values.end());
5228template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5236 privateDeallocate();
5237 this->d_length = npos;
5244template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5254 if (Propagate::value) {
5256 quickSwapExchangeAllocators(other, Propagate());
5259 privateAssignDispatch(
5262 "string<...>::operator=(const string&...): string too long");
5268template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5272 BloombergLP::bslmf::MovableRef<basic_string> rhs)
5274 AllocatorTraits::propagate_on_container_move_assignment::value ||
5275 AllocatorTraits::is_always_equal::value)
5278 AllocatorTraits::propagate_on_container_move_assignment Propagate;
5283 if (Propagate::value) {
5285 quickSwapExchangeAllocators(other, Propagate());
5288 basic_string other(MoveUtil::move(lvalue));
5289 quickSwapRetainAllocators(other);
5292 privateAssignDispatch(
5295 "string<...>::operator=(MovableRef<...>): string too long");
5301template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5302template <
class STRING_VIEW_LIKE_TYPE>
5306 const STRING_VIEW_LIKE_TYPE& rhs)
5309 return privateAssignDispatch(
5312 "string<>::operator=(basic_string_view&): string too long");
5315template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5325template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5330 return assign(1, character);
5333template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5334template <
class ALLOC2>
5338 const std::basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC2>& rhs)
5340 return privateAssignDispatch(
5343 "string<...>::operator=(std::string&...): string too long");
5346#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
5347template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5351 std::initializer_list<CHAR_TYPE> values)
5353 return privateAssignDispatch(
5356 "string<...>::operator=(initializer_list): string too long");
5362template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5365 CHAR_TYPE character)
5367 privateThrowLengthError(newLength > max_size(),
5368 "string<...>::resize(n,c): string too long");
5369 privateResizeRaw(newLength, character);
5372template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5376 privateThrowLengthError(newLength > max_size(),
5377 "string<...>::resize(n): string too long");
5378 privateResizeRaw(newLength, CHAR_TYPE());
5381template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5382template <
class OPERATION>
5385 OPERATION operation)
5387 privateThrowLengthError(newLength > max_size(),
5388 "string<...>::resize_and_overwrite(n, op): string too long");
5390 privateReserveRaw(newLength);
5391 this->d_length = newLength;
5393#ifdef BSLMF_MOVABLEREF_USES_RVALUE_REFERENCES
5395 MoveUtil::move(operation)(this->dataPtr(), newLength));
5398 operation(this->dataPtr(), newLength));
5401 this->d_length = finalLength;
5402 CHAR_TRAITS::assign(*(this->dataPtr() + this->d_length), CHAR_TYPE());
5405template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5410 privateThrowLengthError(newCapacity > max_size(),
5411 "string<...>::reserve(n): string too long");
5412 privateReserveRaw(newCapacity);
5415template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5419 if (this->
size() < this->d_capacity) {
5421 temp.privateAppend(this->
data(),
5423 "string<...>::shrink_to_fit(): string too long");
5424 quickSwapRetainAllocators(temp);
5428template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5436 privateClear(Imp::BASIC_STRING_DEALLOCATE_IN_CLEAR);
5441template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5446 return this->dataPtr();
5449template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5454 return begin() + this->d_length;
5457template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5465template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5475template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5482 return *(
begin() + position);
5485template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5493 privateThrowOutOfRange(position >= length(),
5494 "string<...>::at(n): invalid position");
5496 return *(
begin() + position);
5499template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5509template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5516 return *(
begin() + length() - 1);
5521template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5530template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5534 const CHAR_TYPE *rhs)
5541template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5546 push_back(character);
5550template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5551template <
class STRING_VIEW_LIKE_TYPE>
5555 const STRING_VIEW_LIKE_TYPE& rhs)
5558 return append(strView.
data(),strView.
length());
5561template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5562template <
class ALLOC2>
5566 const std::basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOC2>& rhs)
5568 return append(rhs.begin(),rhs.end());
5571template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5577 return append(suffix,
size_type(0), npos);
5580template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5587 privateThrowOutOfRange(
5588 position > suffix.
length(),
5589 "string<...>::append(const string&,pos,n): invalid position");
5591 if (numChars > suffix.
length() - position) {
5592 numChars = suffix.
length() - position;
5594 return privateAppend(
5595 suffix.
data() + position,
5597 "string<...>::append(const string&,pos,n): string too long");
5600template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5604 const CHAR_TYPE *characterString,
5609 return privateAppend(characterString,
5611 "string<...>::append(char*...): string too long");
5614template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5618 const CHAR_TYPE *characterString)
5622 return append(characterString, CHAR_TRAITS::length(characterString));
5625template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5629 CHAR_TYPE character)
5631 return privateAppend(numChars,
5633 "string<...>::append(n,c): string too long");
5636template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5637template <
class STRING_VIEW_LIKE_TYPE>
5641 const STRING_VIEW_LIKE_TYPE& suffix)
5644 return privateAppend(
5647 "string<...>::append(basic_string_view): string too long");
5650template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5651template <
class STRING_VIEW_LIKE_TYPE>
5654 const STRING_VIEW_LIKE_TYPE& suffix,
5659 privateThrowOutOfRange(
5660 position > strView.
length(),
5661 "string<...>::append(basic_string_view,pos,n): invalid position");
5663 if (numChars > strView.
length() - position) {
5664 numChars = strView.
length() - position;
5666 return privateAppend(
5667 strView.
data() + position,
5669 "string<...>::append(basic_string_view,pos,n): string too long");
5672template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5673template <
class INPUT_ITER>
5679 return privateAppend(first,
5681 "string<...>::append<Iter>(i,j): string too long");
5684#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
5685template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5689 std::initializer_list<CHAR_TYPE> values)
5691 return privateAppend(
5694 "string<...>::append(initializer_list): string too long");
5698template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5700 CHAR_TYPE character)
5702 privateThrowLengthError(length() >= max_size(),
5703 "string<...>::push_back(char): string too long");
5705 if (length() + 1 > capacity()) {
5706 privateReserveRaw(length() + 1);
5708 CHAR_TRAITS::assign(*(
begin() + length()), character);
5710 CHAR_TRAITS::assign(*(
begin() + length()), CHAR_TYPE());
5713template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5719 return this->operator=(replacement);
5722template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5726 BloombergLP::bslmf::MovableRef<basic_string> replacement)
5730 return this->operator=(MoveUtil::move(other));
5733template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5740 privateThrowOutOfRange(
5741 position > replacement.
length(),
5742 "string<...>::assign(const string&,pos,n): invalid position");
5744 if (numChars > replacement.
length() - position) {
5745 numChars = replacement.
length() - position;
5747 return privateAssignDispatch(
5748 replacement.
data() + position,
5750 "string<...>::assign(const string&,pos,n): invalid position");
5753template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5757 const CHAR_TYPE *characterString)
5761 return assign(characterString, CHAR_TRAITS::length(characterString));
5764template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5768 const CHAR_TYPE *characterString,
5773 return privateAssignDispatch(
5776 "string<...>::assign(char*...): string too long");
5779template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5780template <
class STRING_VIEW_LIKE_TYPE>
5784 const STRING_VIEW_LIKE_TYPE& replacement)
5788 return this->operator=(strView);
5791template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5792template <
class STRING_VIEW_LIKE_TYPE>
5796 const STRING_VIEW_LIKE_TYPE& replacement,
5802 privateThrowOutOfRange(
5803 position > strView.
length(),
5804 "string<...>::assign(const StrViewLike&,pos,n): invalid position");
5806 if (numChars > strView.
length() - position) {
5807 numChars = strView.
length() - position;
5809 return privateAssignDispatch(
5810 strView.
data() + position,
5812 "string<...>::assign(const StrViewLike&,pos,n): invalid position");
5815template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5816template <
class ALLOC2>
5820 const std::basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOC2>&
string)
5822 return this->operator=(
string);
5825template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5829 CHAR_TYPE character)
5831 return privateAssignDispatch(
5834 "string<...>::assign(n,c): string too long");
5837template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5838template <
class INPUT_ITER>
5844 return privateAssignDispatch(
5847 "string<...>::assign<Iter>(i,j): string too long");
5850#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
5851template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5855 std::initializer_list<CHAR_TYPE> values)
5857 return privateAssignDispatch(
5860 "string<...>::assign(initializer_list): string too long");
5864template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5866basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>&
5871 return insert(position, other,
size_type(0), npos);
5874template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5882 privateThrowOutOfRange(
5883 position > length(),
5884 "string<...>::insert(pos,const string&...): invalid position");
5885 privateThrowOutOfRange(
5886 sourcePosition > other.
length(),
5887 "string<...>::insert(pos,const string&...): invalid source position");
5889 if (numChars > other.
length() - sourcePosition) {
5890 numChars = other.
length() - sourcePosition;
5892 privateThrowLengthError(
5893 numChars > max_size() - length(),
5894 "string<...>::insert(pos,const string&...): string too long");
5895 return privateInsertRaw(position, other.
data() + sourcePosition, numChars);
5898template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5902 const CHAR_TYPE *characterString,
5907 privateThrowOutOfRange(
5908 position > length(),
5909 "string<...>::insert(pos,char*...): invalid position");
5911 privateThrowLengthError(
5912 numChars > max_size() - length(),
5913 "string<...>::insert(pos,char*...): string too long");
5914 return privateInsertRaw(position, characterString, numChars);
5917template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5922 const CHAR_TYPE *characterString)
5926 return insert(position,
5928 CHAR_TRAITS::length(characterString));
5931template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5935 CHAR_TYPE character)
5937 privateThrowOutOfRange(position > length(),
5938 "string<...>::insert(pos,n,c): invalid position");
5940 privateThrowLengthError(numChars > max_size() - length(),
5941 "string<...>::insert(pos,n,c): string too long");
5942 return privateReplaceRaw(position,
size_type(0), numChars, character);
5945template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5948 CHAR_TYPE character)
5955 return begin() + pos;
5958#if defined(BSLS_PLATFORM_CMP_SUN) && BSLS_PLATFORM_CMP_VERSION < 0x5130
5966# define BSLSTL_INSERT_RETURN_TYPE CHAR_TYPE *
5968# define BSLSTL_INSERT_RETURN_TYPE \
5969 typename basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>::iterator
5972template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5973template <
class INPUT_ITER>
5984 privateInsertDispatch(position, first, last);
5985 return begin() + pos;
5988#undef BSLSTL_INSERT_RETURN_TYPE
5990template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
5995 CHAR_TYPE character)
6001 insert(pos, numChars, character);
6002 return begin() + pos;
6005template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6006template <
class STRING_VIEW_LIKE_TYPE>
6010 const STRING_VIEW_LIKE_TYPE& other)
6013 privateThrowOutOfRange(
6014 position > length(),
6015 "string<...>::insert(pos,const string_view&): invalid position");
6016 privateThrowLengthError(
6017 strView.
length() > max_size() - length(),
6018 "string<...>::insert(pos,const string_view&): string too long");
6019 return privateInsertRaw(position, strView.
data(), strView.
length());
6022template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6023template <
class STRING_VIEW_LIKE_TYPE>
6027 const STRING_VIEW_LIKE_TYPE& other,
6032 privateThrowOutOfRange(
6033 position > length(),
6034 "string<...>::insert(pos,const string_view&...): invalid position");
6035 privateThrowOutOfRange(sourcePosition > strView.
length(),
6036 "string<...>::insert(pos,const string_view&...): "
6037 "invalid source position");
6039 if (numChars > strView.
length() - sourcePosition) {
6040 numChars = strView.
length() - sourcePosition;
6042 privateThrowLengthError(
6043 numChars > max_size() - length(),
6044 "string<...>::insert(pos,const string&...): string too long");
6045 return privateInsertRaw(position,
6046 strView.
data() + sourcePosition,
6050#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
6051template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6055 const_iterator position,
6056 std::initializer_list<CHAR_TYPE> values)
6061 size_type pos = position -
cbegin();
6062 privateInsertDispatch(position, values.begin(), values.end());
6063 return begin() + pos;
6067template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6068basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>&
6072 privateThrowOutOfRange(position > length(),
6073 "string<...>::erase(pos,n): invalid position");
6075 if (numChars > length() - position) {
6076 numChars = length() - position;
6079 this->d_length -= numChars;
6080 CHAR_TRAITS::move(this->dataPtr() + position,
6081 this->dataPtr() + position + numChars,
6082 this->d_length - position);
6083 CHAR_TRAITS::assign(*(
begin() + length()), CHAR_TYPE());
6088template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6099 CHAR_TRAITS::move(&*dstPosition, &*postPosition,
cend() - postPosition);
6102 CHAR_TRAITS::assign(*(this->dataPtr() + length()), CHAR_TYPE());
6107template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6120 if (first != last) {
6121 CHAR_TRAITS::move(&*dstFirst, &*last,
cend() - last);
6123 this->d_length -= last - first;
6124 CHAR_TRAITS::assign(*(this->dataPtr() + length()), CHAR_TYPE());
6130template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6137 CHAR_TRAITS::assign(*(
begin() + length()), CHAR_TYPE());
6140template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6147 privateThrowOutOfRange(
6148 length() < outPosition,
6149 "string<...>::replace(pos,const string&...): invalid position");
6150 if (outNumChars > length() - outPosition) {
6151 outNumChars = length() - outPosition;
6153 privateThrowLengthError(
6154 replacement.
length() > outNumChars &&
6155 replacement.
length() - outNumChars > max_size() - length(),
6156 "string<...>::replace(pos,const string&...): string too long");
6157 return privateReplaceRaw(outPosition,
6163template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6172 privateThrowOutOfRange(
6173 length() < outPosition,
6174 "string<...>::replace(pos,const string&...): invalid position");
6176 if (outNumChars > length() - outPosition) {
6177 outNumChars = length() - outPosition;
6179 privateThrowOutOfRange(
6180 position > replacement.
length(),
6181 "string<...>::replace(pos,const string&...): invalid position");
6183 if (numChars > replacement.
length() - position) {
6184 numChars = replacement.
length() - position;
6186 privateThrowLengthError(
6187 numChars > outNumChars &&
6188 numChars - outNumChars > max_size() - length(),
6189 "string<...>::replace(pos,const string&...): string too long");
6190 return privateReplaceRaw(outPosition,
6192 replacement.
data() + position,
6196template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6201 const CHAR_TYPE *characterString,
6206 privateThrowOutOfRange(
6207 length() < outPosition,
6208 "string<...>::replace(pos,char*...): invalid position");
6210 if (outNumChars > length() - outPosition) {
6211 outNumChars = length() - outPosition;
6214 privateThrowLengthError(
6215 numChars > outNumChars &&
6216 numChars - outNumChars > max_size() - length(),
6217 "string<...>::replace(pos,char*...): string too long");
6218 return privateReplaceRaw(outPosition,
6224template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6230 const CHAR_TYPE *characterString)
6234 return replace(outPosition,
6237 CHAR_TRAITS::length(characterString));
6240template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6245 CHAR_TYPE character)
6247 privateThrowOutOfRange(
6248 length() < outPosition,
6249 "string<...>::replace(pos,n,c): invalid position");
6250 if (outNumChars > length() - outPosition) {
6251 outNumChars = length() - outPosition;
6253 privateThrowLengthError(
6254 numChars > outNumChars &&
6255 numChars - outNumChars > max_size() - length(),
6256 "string<...>::replace(pos,n,c): string too long");
6257 return privateReplaceRaw(outPosition,
6263template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6264template <
class STRING_VIEW_LIKE_TYPE>
6269 const STRING_VIEW_LIKE_TYPE& replacement)
6271 privateThrowOutOfRange(
6272 length() < outPosition,
6273 "string<...>::replace(pos,const strView&...): invalid position");
6274 if (outNumChars > length() - outPosition) {
6275 outNumChars = length() - outPosition;
6279 privateThrowLengthError(
6280 strView.
length() > outNumChars &&
6281 strView.
length() - outNumChars > max_size() - length(),
6282 "string<...>::replace(pos,const strView&...): string too long");
6283 return privateReplaceRaw(outPosition,
6289template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6290template <
class STRING_VIEW_LIKE_TYPE>
6295 const STRING_VIEW_LIKE_TYPE& replacement,
6299 privateThrowOutOfRange(
6300 length() < outPosition,
6301 "string<...>::replace(pos,const strView&...): invalid position");
6303 if (outNumChars > length() - outPosition) {
6304 outNumChars = length() - outPosition;
6308 privateThrowOutOfRange(
6309 position > strView.
length(),
6310 "string<...>::replace(pos,const strView&...): invalid position");
6312 if (numChars > strView.
length() - position) {
6313 numChars = strView.
length() - position;
6315 privateThrowLengthError(
6316 numChars > outNumChars &&
6317 numChars - outNumChars > max_size() - length(),
6318 "string<...>::replace(pos,const strView&...): string too long");
6319 return privateReplaceRaw(outPosition,
6321 strView.
data() + position,
6325template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6340 privateThrowLengthError(
6341 replacement.
length() > outNumChars &&
6342 replacement.
length() - outNumChars > max_size() - length(),
6343 "string<...>::replace(const string&...): string too long");
6345 return privateReplaceRaw(outPosition,
6351template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6352template <
class STRING_VIEW_LIKE_TYPE>
6357 const STRING_VIEW_LIKE_TYPE& replacement)
6368 privateThrowLengthError(
6369 strView.
length() > outNumChars &&
6370 strView.
length() - outNumChars > max_size() - length(),
6371 "string<...>::replace(const strView&...): string too long");
6373 return privateReplaceRaw(outPosition,
6380template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6385 const CHAR_TYPE *characterString,
6396 privateThrowLengthError(
6397 numChars > outNumChars &&
6398 numChars - outNumChars > max_size() - length(),
6399 "string<...>::replace(char*...): string too long");
6400 return privateReplaceRaw(outPosition,
6406template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6412 const CHAR_TYPE *characterString)
6420 return replace(first,
6423 CHAR_TRAITS::length(characterString));
6426template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6432 CHAR_TYPE character)
6441 privateThrowLengthError(numChars > outNumChars &&
6442 numChars - outNumChars > max_size() - length(),
6443 "string<...>::replace(n,c): string too long");
6444 return privateReplaceRaw(outPosition, outNumChars, numChars, character);
6447template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6448template <
class INPUT_ITER>
6454 INPUT_ITER stringFirst,
6455 INPUT_ITER stringLast)
6464 return privateReplaceDispatch(outPosition,
6469 BloombergLP::bslmf::Nil());
6474template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6479 return this->dataPtr();
6482template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6486 AllocatorTraits::propagate_on_container_swap::value ||
6487 AllocatorTraits::is_always_equal::value)
6490 AllocatorTraits::propagate_on_container_swap Propagate;
6492 if (Propagate::value) {
6493 quickSwapExchangeAllocators(other, Propagate());
6496 get_allocator() == other.get_allocator())) {
6497 quickSwapRetainAllocators(other);
6502 basic_string toThisCopy(MoveUtil::move(other), get_allocator());
6503 basic_string toOtherCopy(MoveUtil::move(*
this),
6504 other.get_allocator());
6506 this->quickSwapRetainAllocators(toThisCopy);
6507 other.quickSwapRetainAllocators(toOtherCopy);
6515template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6521 return this->dataPtr();
6524template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6533template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6539 return begin() + this->d_length;
6542template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6551template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6560template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6569template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6578template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6589template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6595 return this->d_length;
6598template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6604 return this->d_length;
6607template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6616 size_type allocMaxSize = AllocatorTraits::max_size(get_allocator()) - 1;
6617 return allocMaxSize < stringMaxSize ? allocMaxSize : stringMaxSize;
6620template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6626 return this->d_capacity;
6629template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6634 return this->d_length == 0;
6639template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6647 return *(
begin() + position);
6650template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6657 privateThrowOutOfRange(position >= length(),
6658 "const string<...>::at(n): invalid position");
6659 return *(
begin() + position);
6662template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6672template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6679 return *(
end() - 1);
6682template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6690 privateThrowOutOfRange(
6691 length() < position,
6692 "const string<...>::copy(str,pos,n): invalid position");
6693 if (numChars > length() - position) {
6694 numChars = length() - position;
6696 CHAR_TRAITS::move(characterString, this->dataPtr() + position, numChars);
6702template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6708 return this->dataPtr();
6711template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6717 return this->dataPtr();
6720template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6726 return this->allocatorRef();
6729template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6737 return find(substring.data(), position, substring.length());
6740template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6741template <
class STRING_VIEW_LIKE_TYPE>
6745 const STRING_VIEW_LIKE_TYPE& substring,
6751 return find(strView.
data(), position, strView.
length());
6754template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6757 const CHAR_TYPE *substring,
6763 size_type remChars = length() - position;
6764 if (position > length() || numChars > remChars) {
6767 if (0 == numChars) {
6770 const CHAR_TYPE *thisString = this->dataPtr() + position;
6771 const CHAR_TYPE *nextString;
6772 for (remChars -= numChars - 1;
6773 0 != (nextString = BSLSTL_CHAR_TRAITS::find(thisString,
6776 remChars -= ++nextString - thisString, thisString = nextString)
6778 if (0 == CHAR_TRAITS::compare(nextString, substring, numChars)) {
6779 return nextString - this->dataPtr();
6785template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6789 const CHAR_TYPE *substring,
6794 return find(substring, position, CHAR_TRAITS::length(substring));
6797template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6802 if (position >= length()) {
6805 const CHAR_TYPE *result =
6806 BSLSTL_CHAR_TRAITS::find(this->dataPtr() + position,
6807 length() - position,
6809 return result ? result - this->dataPtr() : npos;
6812template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6820 return rfind(substring.data(), position, substring.length());
6823template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6824template <
class STRING_VIEW_LIKE_TYPE>
6828 const STRING_VIEW_LIKE_TYPE& substring,
6834 return rfind(strView.
data(), position, strView.
length());
6837template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6840 const CHAR_TYPE *characterString,
6846 if (0 == numChars) {
6847 return position > length() ? length() : position;
6849 if (numChars <= length()) {
6850 if (position > length() - numChars) {
6851 position = length() - numChars;
6853 const CHAR_TYPE *thisString = this->dataPtr() + position;
6854 for (; position != npos; --thisString, --position) {
6855 if (0 == CHAR_TRAITS::compare(thisString,
6865template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6869 const CHAR_TYPE *characterString,
6874 return rfind(characterString,
6876 CHAR_TRAITS::length(characterString));
6879template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6885 return rfind(&character, position,
size_type(1));
6888template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6896 return find_first_of(characterString.data(),
6898 characterString.length());
6901template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6902template <
class STRING_VIEW_LIKE_TYPE>
6906 const STRING_VIEW_LIKE_TYPE& characterString,
6912 return find_first_of(strView.
data(), position, strView.
length());
6915template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6918 const CHAR_TYPE *characterString,
6924 if (0 < numChars && position < length()) {
6925 for (
const CHAR_TYPE *current = this->dataPtr() + position;
6926 current != this->dataPtr() + length();
6929 if (BSLSTL_CHAR_TRAITS::find(characterString, numChars, *current)
6931 return current - this->dataPtr();
6938template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6942 const CHAR_TYPE *characterString,
6947 return find_first_of(characterString,
6949 CHAR_TRAITS::length(characterString));
6952template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6956 CHAR_TYPE character,
6959 return find_first_of(&character, position,
size_type(1));
6962template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6970 return find_last_of(characterString.data(),
6972 characterString.length());
6975template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6976template <
class STRING_VIEW_LIKE_TYPE>
6980 const STRING_VIEW_LIKE_TYPE& characterString,
6986 return find_last_of(strView.
data(), position, strView.
length());
6989template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
6992 const CHAR_TYPE *characterString,
6998 if (0 < numChars && 0 < length()) {
6999 size_type remChars = position < length() ? position : length() - 1;
7000 for (
const CHAR_TYPE *current = this->dataPtr() + remChars;
7004 if (BSLSTL_CHAR_TRAITS::find(
7005 characterString, numChars, *current)) {
7006 return current - this->dataPtr();
7008 if (current == this->dataPtr()) {
7016template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
7020 const CHAR_TYPE *characterString,
7025 return find_last_of(characterString,
7027 CHAR_TRAITS::length(characterString));
7030template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
7034 CHAR_TYPE character,
7037 return find_last_of(&character, position,
size_type(1));
7040template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
7048 return find_first_not_of(characterString.data(),
7050 characterString.length());
7053template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
7054template <
class STRING_VIEW_LIKE_TYPE>
7058 const STRING_VIEW_LIKE_TYPE& characterString,
7064 return find_first_not_of(strView.
data(), position, strView.
length());
7067template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
7070 const CHAR_TYPE *characterString,
7076 if (position < length()) {
7077 const CHAR_TYPE *last = this->dataPtr() + length();
7078 for (
const CHAR_TYPE *current = this->dataPtr() + position;
7082 if (!BSLSTL_CHAR_TRAITS::find(
7083 characterString, numChars, *current)) {
7084 return current - this->dataPtr();
7091template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
7095 const CHAR_TYPE *characterString,
7100 return find_first_not_of(characterString,
7102 CHAR_TRAITS::length(characterString));
7105template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
7109 CHAR_TYPE character,
7112 return find_first_not_of(&character, position,
size_type(1));
7115template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
7123 return find_last_not_of(characterString.data(),
7125 characterString.length());
7128template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
7129template <
class STRING_VIEW_LIKE_TYPE>
7133 const STRING_VIEW_LIKE_TYPE& characterString,
7139 return find_last_not_of(strView.
data(), position, strView.
length());
7142template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
7145 const CHAR_TYPE *characterString,
7152 size_type remChars = position < length() ? position : length() - 1;
7153 for (
const CHAR_TYPE *current = this->dataPtr() + remChars;
7155 --current, --remChars)
7157 if (!BSLSTL_CHAR_TRAITS::find(
7158 characterString, numChars, *current)) {
7159 return current - this->dataPtr();
7166template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
7170 const CHAR_TYPE *characterString,
7175 return find_last_not_of(characterString,
7177 CHAR_TRAITS::length(characterString));
7180template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
7184 CHAR_TYPE character,
7187 return find_last_not_of(&character, position,
size_type(1));
7190template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
7196 return (length() >= characterString.length() &&
7197 0 == CHAR_TRAITS::compare(
data(),
7198 characterString.data(),
7199 characterString.size()));
7202template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
7207 return (0 < length() && CHAR_TRAITS::eq(*
data(), character));
7210template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
7213 const CHAR_TYPE *characterString)
const
7217 std::size_t strLength = CHAR_TRAITS::length(characterString);
7218 return (length() >= strLength &&
7219 0 == CHAR_TRAITS::compare(
data(),
7224template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
7230 return (length() >= characterString.length() &&
7231 0 == CHAR_TRAITS::compare(
7232 data() + length() - characterString.length(),
7233 characterString.data(),
7234 characterString.size()));
7237template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
7242 return (0 < length() &&
7243 CHAR_TRAITS::eq(*(
data()+ length() - 1), character));
7246template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
7249 const CHAR_TYPE *characterString)
const
7253 std::size_t strLength = CHAR_TRAITS::length(characterString);
7254 return (length() >= strLength &&
7255 0 == CHAR_TRAITS::compare(
data() + length() - strLength,
7260template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
7268 ALLOCATOR>(*
this, position, numChars);
7271template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
7283template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
7289 privateThrowOutOfRange(
7290 length() < position,
7291 "const string<...>::compare(pos,n,...): invalid position");
7292 if (numChars > length() - position) {
7293 numChars = length() - position;
7295 return privateCompareRaw(position, numChars, other.
data(), other.
length());
7298template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
7306 privateThrowOutOfRange(
7307 length() < lhsPosition,
7308 "const string<...>::compare(pos,n,...): invalid position");
7309 if (lhsNumChars > length() - lhsPosition) {
7310 lhsNumChars = length() - lhsPosition;
7312 privateThrowOutOfRange(
7313 other.
length() < otherPosition,
7314 "const string<...>::compare(pos,n,...): invalid position");
7315 if (otherNumChars > other.
length() - otherPosition) {
7316 otherNumChars = other.
length() - otherPosition;
7318 return privateCompareRaw(lhsPosition,
7320 other.dataPtr() + otherPosition,
7324template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
7327 const CHAR_TYPE *other)
const
7334 CHAR_TRAITS::length(other));
7337template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
7341 const CHAR_TYPE *other,
7346 privateThrowOutOfRange(
7347 length() < lhsPosition,
7348 "const string<...>::compare(pos,n,...): invalid position");
7349 if (lhsNumChars > length() - lhsPosition) {
7350 lhsNumChars = length() - lhsPosition;
7352 return privateCompareRaw(lhsPosition,
7358template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
7363 const CHAR_TYPE *other)
const
7367 return compare(lhsPosition,
7370 CHAR_TRAITS::length(other));
7373template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
7374template <
class STRING_VIEW_LIKE_TYPE>
7377 const STRING_VIEW_LIKE_TYPE& other
7389template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
7390template <
class STRING_VIEW_LIKE_TYPE>
7394 const STRING_VIEW_LIKE_TYPE& other
7397 privateThrowOutOfRange(
7398 length() < position,
7399 "string<...>::compare(pos,n,StrViewLike): invalid position");
7403 if (numChars > length() - position) {
7404 numChars = length() - position;
7406 return privateCompareRaw(position,
7412template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
7413template <
class STRING_VIEW_LIKE_TYPE>
7417 const STRING_VIEW_LIKE_TYPE& other,
7422 privateThrowOutOfRange(
7423 length() < lhsPosition,
7424 "string<...>::compare(pos,n, StrViewLike,...): invalid lhs position");
7428 privateThrowOutOfRange(
7429 strView.
length() < otherPosition,
7430 "string<...>::compare(pos,n, StrViewLike,...): invalid rhs position");
7432 if (lhsNumChars > length() - lhsPosition) {
7433 lhsNumChars = length() - lhsPosition;
7435 if (otherNumChars > other.length() - otherPosition) {
7436 otherNumChars = other.length() - otherPosition;
7438 return privateCompareRaw(lhsPosition,
7440 strView.
data() + otherPosition,
7444template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
7453template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
7458 using ::BloombergLP::bslh::hashAppend;
7459 ::BloombergLP::bslh::Hash<>::HashAlgorithm hashAlg;
7460 hashAlg(input.data(),
sizeof(CHAR_TYPE) * input.size());
7462 return static_cast<std::size_t
>(hashAlg.computeHash());
7465template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
7468operator()(
const CHAR_TYPE *input)
const
7471 using ::BloombergLP::bslh::hashAppend;
7472 std::size_t length = CHAR_TRAITS::length(input);
7473 ::BloombergLP::bslh::Hash<>::HashAlgorithm hashAlg;
7474 hashAlg(input,
sizeof(CHAR_TYPE) * length);
7476 return static_cast<std::size_t
>(hashAlg.computeHash());
7479#if defined(BSLS_PLATFORM_CMP_SUN) && BSLS_PLATFORM_CMP_VERSION < 0x5130
7484 using ::BloombergLP::bslh::hashAppend;
7485 ::BloombergLP::bslh::Hash<>::HashAlgorithm hashAlg;
7486 hashAlg(input.
data(), input.
size());
7488 return static_cast<std::size_t
>(hashAlg.computeHash());
7495 using ::BloombergLP::bslh::hashAppend;
7496 std::size_t length = char_traits<char>::length(input);
7497 ::BloombergLP::bslh::Hash<>::HashAlgorithm hashAlg;
7498 hashAlg(input, length);
7500 return static_cast<std::size_t
>(hashAlg.computeHash());
7506 using ::BloombergLP::bslh::hashAppend;
7507 ::BloombergLP::bslh::Hash<>::HashAlgorithm hashAlg;
7508 hashAlg(input.data(),
sizeof(
wchar_t) * input.size());
7510 return static_cast<std::size_t
>(hashAlg.computeHash());
7517 using ::BloombergLP::bslh::hashAppend;
7518 std::size_t length = char_traits<wchar_t>::length(input);
7519 ::BloombergLP::bslh::Hash<>::HashAlgorithm hashAlg;
7520 hashAlg(input,
sizeof(
wchar_t) * length);
7522 return static_cast<std::size_t
>(hashAlg.computeHash());
7530template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
7532void bsl::swap(basic_string<CHAR_TYPE,CHAR_TRAITS, ALLOCATOR>& a,
7533 basic_string<CHAR_TYPE,CHAR_TRAITS, ALLOCATOR>& b)
7540template <
class CHAR_TYPE,
7543 class OTHER_CHAR_TYPE>
7546bsl::erase(basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>& str,
7547 const OTHER_CHAR_TYPE& c)
7549 typename basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>::iterator it =
7550 bsl::remove(str.begin(), str.end(), c);
7552 typename basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>::size_type
7553 result = bsl::distance(it, str.end());
7555 str.erase(it, str.end());
7560template <
class CHAR_TYPE,
7563 class UNARY_PREDICATE>
7566bsl::erase_if(basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>& str,
7567 const UNARY_PREDICATE& pred)
7569 typename basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>::iterator it =
7570 bsl::remove_if(str.begin(), str.end(), pred);
7572 typename basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>::size_type
7573 result = bsl::distance(it, str.end());
7575 str.erase(it, str.end());
7581template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
7583bool bsl::operator==(
const basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC>& lhs,
7584 const basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC>& rhs)
7587 return lhs.size() == rhs.size()
7588 && 0 == CHAR_TRAITS::compare(lhs.data(), rhs.data(), lhs.size());
7591template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC1,
class ALLOC2>
7595 const std::basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC2>& rhs)
7598 return lhs.size() == rhs.size()
7599 && 0 == CHAR_TRAITS::compare(lhs.data(), rhs.data(), lhs.size());
7602template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
7604bool bsl::operator==(
const basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC>& lhs,
7605 const CHAR_TYPE *rhs)
7609 std::size_t len = CHAR_TRAITS::length(rhs);
7610 return lhs.size() == len
7611 && 0 == CHAR_TRAITS::compare(lhs.data(), rhs, len);
7614#ifdef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
7616template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
7617inline bsl::String_ComparisonCategoryType<CHAR_TRAITS>
7618bsl::operator<=>(
const basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC>& lhs,
7619 const basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC>& rhs)
7622 return static_cast<String_ComparisonCategoryType<CHAR_TRAITS>
>(
7623 lhs.compare(rhs) <=> 0);
7626template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
7627inline bsl::String_ComparisonCategoryType<CHAR_TRAITS>
7628bsl::operator<=>(
const basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC>& lhs,
7629 const CHAR_TYPE *rhs)
7632 return static_cast<String_ComparisonCategoryType<CHAR_TRAITS>
>(
7633 lhs.compare(rhs) <=> 0);
7636template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC1,
class ALLOC2>
7637inline bsl::String_ComparisonCategoryType<CHAR_TRAITS>
7639 const std::basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC2>& rhs)
7642 return static_cast<String_ComparisonCategoryType<CHAR_TRAITS>
>(
7643 lhs.compare(rhs) <=> 0);
7648template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC1,
class ALLOC2>
7651bsl::operator==(
const std::basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC1>& lhs,
7655 return lhs.size() == rhs.size()
7656 && 0 == CHAR_TRAITS::compare(lhs.data(), rhs.data(), lhs.size());
7659template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
7662 const basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC>& rhs)
7666 std::size_t len = CHAR_TRAITS::length(lhs);
7667 return len == rhs.size()
7668 && 0 == CHAR_TRAITS::compare(lhs, rhs.data(), len);
7671template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
7673bool bsl::operator!=(
const basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC>& lhs,
7674 const basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC>& rhs)
7677 return !(lhs == rhs);
7680template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC1,
class ALLOC2>
7683bsl::operator!=(
const std::basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC1>& lhs,
7687 return !(lhs == rhs);
7690template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC1,
class ALLOC2>
7694 const std::basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC2>& rhs)
7697 return !(lhs == rhs);
7700template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
7703 const basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC>& rhs)
7707 return !(lhs == rhs);
7710template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
7712bool bsl::operator!=(
const basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC>& lhs,
7713 const CHAR_TYPE *rhs)
7717 return !(lhs == rhs);
7720template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
7721bool bsl::operator<(
const basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC>& lhs,
7722 const basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC>& rhs)
7725 const std::size_t minLen = lhs.length() < rhs.length()
7726 ? lhs.length() : rhs.length();
7728 int ret = CHAR_TRAITS::compare(lhs.data(), rhs.data(), minLen);
7730 return lhs.length() < rhs.length();
7735template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC1,
class ALLOC2>
7737bsl::operator<(
const std::basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC1>& lhs,
7741 const std::size_t minLen = lhs.length() < rhs.length()
7742 ? lhs.length() : rhs.length();
7744 int ret = CHAR_TRAITS::compare(lhs.data(), rhs.data(), minLen);
7746 return lhs.length() < rhs.length();
7751template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC1,
class ALLOC2>
7754 const std::basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC2>& rhs)
7757 const std::size_t minLen = lhs.length() < rhs.length()
7758 ? lhs.length() : rhs.length();
7760 int ret = CHAR_TRAITS::compare(lhs.data(), rhs.data(), minLen);
7762 return lhs.length() < rhs.length();
7767template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
7769 const basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC>& rhs)
7773 const std::size_t lhsLen = CHAR_TRAITS::length(lhs);
7774 const std::size_t minLen = lhsLen < rhs.length() ? lhsLen : rhs.length();
7776 int ret = CHAR_TRAITS::compare(lhs, rhs.data(), minLen);
7778 return lhsLen < rhs.length();
7783template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
7784bool bsl::operator<(
const basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC>& lhs,
7785 const CHAR_TYPE *rhs)
7789 const std::size_t rhsLen = CHAR_TRAITS::length(rhs);
7790 const std::size_t minLen = rhsLen < lhs.length() ? rhsLen : lhs.length();
7792 int ret = CHAR_TRAITS::compare(lhs.data(), rhs, minLen);
7794 return lhs.length() < rhsLen;
7799template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
7801bool bsl::operator>(
const basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC>& lhs,
7802 const basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC>& rhs)
7808template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC1,
class ALLOC2>
7811bsl::operator>(
const std::basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC1>& lhs,
7818template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC1,
class ALLOC2>
7822 const std::basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC2>& rhs)
7828template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
7831 const basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC>& rhs)
7838template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
7840bool bsl::operator>(
const basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC>& lhs,
7841 const CHAR_TYPE *rhs)
7848template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
7850bool bsl::operator<=(
const basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC>& lhs,
7851 const basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC>& rhs)
7854 return !(rhs < lhs);
7857template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC1,
class ALLOC2>
7860bsl::operator<=(
const std::basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC1>& lhs,
7864 return !(rhs < lhs);
7867template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC1,
class ALLOC2>
7871 const std::basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC2>& rhs)
7874 return !(rhs < lhs);
7877template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
7880 const basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC>& rhs)
7884 return !(rhs < lhs);
7887template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
7889bool bsl::operator<=(
const basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC>& lhs,
7890 const CHAR_TYPE *rhs)
7894 return !(rhs < lhs);
7897template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
7899bool bsl::operator>=(
const basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC>& lhs,
7900 const basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC>& rhs)
7903 return !(lhs < rhs);
7906template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC1,
class ALLOC2>
7909bsl::operator>=(
const std::basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC1>& lhs,
7913 return !(lhs < rhs);
7916template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC1,
class ALLOC2>
7920 const std::basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC2>& rhs)
7923 return !(lhs < rhs);
7926template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
7929 const basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC>& rhs)
7933 return !(lhs < rhs);
7936template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
7938bool bsl::operator>=(
const basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC>& lhs,
7939 const CHAR_TYPE *rhs)
7943 return !(lhs < rhs);
7948template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
7950bsl::operator+(
const basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>& lhs,
7951 const basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>& rhs)
7953 basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR> result(
7955 select_on_container_copy_construction(lhs.get_allocator()));
7956 result.
reserve(lhs.length() + rhs.length());
7962#ifdef BSLSTL_STRING_SUPPORT_RVALUE_ADDITION_OPERATORS
7963template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
7966 const basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>& rhs)
7968 basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>& lvalue = lhs;
7970 return basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>(
7971 BloombergLP::bslmf::MovableRefUtil::move(lvalue));
7974template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
7976bsl::operator+(
const basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>& lhs,
7979 basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>& lvalue = rhs;
7981 return basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>(
7982 BloombergLP::bslmf::MovableRefUtil::move(lvalue));
7985template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
7990 basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>& lvalue = lhs;
7992 return basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>(
7993 BloombergLP::bslmf::MovableRefUtil::move(lvalue));
7997template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC1,
class ALLOC2>
7999bsl::operator+(
const std::basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC1>& lhs,
8004 select_on_container_copy_construction(rhs.get_allocator()));
8006 result.
append(lhs.c_str(), lhs.length());
8011#ifdef BSLSTL_STRING_SUPPORT_RVALUE_ADDITION_OPERATORS
8012template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC1,
class ALLOC2>
8014bsl::operator+(
const std::basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC1>& lhs,
8017 basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOC2>& lvalue = rhs;
8018 lvalue.
insert(0, lhs.c_str(), lhs.size());
8019 return basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOC2>(
8020 BloombergLP::bslmf::MovableRefUtil::move(lvalue));
8024template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC1,
class ALLOC2>
8027 const std::basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC2>& rhs)
8031 select_on_container_copy_construction(lhs.get_allocator()));
8034 result.
append(rhs.c_str(), rhs.length());
8038#ifdef BSLSTL_STRING_SUPPORT_RVALUE_ADDITION_OPERATORS
8039template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC1,
class ALLOC2>
8042 const std::basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOC2>& rhs)
8044 basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOC1>& lvalue = lhs;
8045 lvalue.
append(rhs.c_str(), rhs.length());
8046 return basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOC1>(
8047 BloombergLP::bslmf::MovableRefUtil::move(lvalue));
8051template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
8054 const basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>& rhs)
8058 typename basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>::size_type
8059 lhsLength = CHAR_TRAITS::length(lhs);
8061 basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR> result(
8063 select_on_container_copy_construction(rhs.get_allocator()));
8064 result.
reserve(lhsLength + rhs.length());
8065 result.append(lhs, lhsLength);
8070#ifdef BSLSTL_STRING_SUPPORT_RVALUE_ADDITION_OPERATORS
8071template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
8078 basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>& lvalue = rhs;
8079 lvalue.insert(0, lhs);
8080 return basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>(
8081 BloombergLP::bslmf::MovableRefUtil::move(lvalue));
8085template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
8088 const basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>& rhs)
8090 basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR> result(
8092 select_on_container_copy_construction(rhs.get_allocator()));
8093 result.
reserve(1 + rhs.length());
8094 result.push_back(lhs);
8099#ifdef BSLSTL_STRING_SUPPORT_RVALUE_ADDITION_OPERATORS
8100template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
8105 basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>& lvalue = rhs;
8106 lvalue.
insert(lvalue.begin(), lhs);
8107 return basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>(
8108 BloombergLP::bslmf::MovableRefUtil::move(lvalue));
8113template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
8115bsl::operator+(
const basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>& lhs,
8116 const CHAR_TYPE *rhs)
8119 typename basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>::size_type
8120 rhsLength = CHAR_TRAITS::length(rhs);
8122 basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR> result(
8124 select_on_container_copy_construction(lhs.get_allocator()));
8125 result.reserve(lhs.length() + rhsLength);
8127 result.append(rhs, rhsLength);
8131#ifdef BSLSTL_STRING_SUPPORT_RVALUE_ADDITION_OPERATORS
8132template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
8135 const CHAR_TYPE *rhs)
8139 basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>& lvalue = lhs;
8141 return basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>(
8142 BloombergLP::bslmf::MovableRefUtil::move(lvalue));
8146template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
8148bsl::operator+(
const basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>& lhs,
8151 basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR> result(
8153 select_on_container_copy_construction(lhs.get_allocator()));
8154 result.
reserve(lhs.length() + 1);
8156 result.push_back(rhs);
8160#ifdef BSLSTL_STRING_SUPPORT_RVALUE_ADDITION_OPERATORS
8161template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
8166 basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>& lvalue = lhs;
8168 return basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>(
8169 BloombergLP::bslmf::MovableRefUtil::move(lvalue));
8174template <
class CHAR_TYPE,
class CHAR_TRAITS>
8176 std::basic_streambuf<CHAR_TYPE, CHAR_TRAITS> *buf,
8181 CHAR_TYPE fillChar = os.fill();
8183 for (std::size_t i = 0; i < n; ++i) {
8184 if (CHAR_TRAITS::eq_int_type(buf->sputc(fillChar), CHAR_TRAITS::eof()))
8193template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
8194std::basic_ostream<CHAR_TYPE, CHAR_TRAITS>&
8196 const basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>& str)
8198 typedef std::basic_ostream<CHAR_TYPE, CHAR_TRAITS> Ostrm;
8199 typename Ostrm::sentry sentry(os);
8204 std::size_t n = str.size();
8205 std::size_t padLen = 0;
8206 bool left = (os.flags() & Ostrm::left) != 0;
8207 std::streamsize w = os.width(0);
8209 std::basic_streambuf<CHAR_TYPE, CHAR_TRAITS> *buf = os.rdbuf();
8211 if (w > 0 && std::size_t(w) > n) {
8212 padLen = std::size_t(w) - n;
8219 ok = ok && (buf->sputn(str.data(), std::streamsize(n)) ==
8220 std::streamsize(n));
8228 os.setstate(Ostrm::failbit);
8234template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
8235std::basic_istream<CHAR_TYPE, CHAR_TRAITS>&
8237 basic_string<CHAR_TYPE,CHAR_TRAITS, ALLOCATOR>& str)
8239 typedef std::basic_istream<CHAR_TYPE, CHAR_TRAITS> Istrm;
8240 typename Istrm::sentry sentry(is);
8243 std::basic_streambuf<CHAR_TYPE, CHAR_TRAITS> *buf = is.rdbuf();
8244 typedef std::ctype<CHAR_TYPE> CType;
8246 const std::locale& loc = is.getloc();
8247 const CType& ctype = std::use_facet<CType>(loc);
8250 std::streamsize n = is.width(0);
8252 n = std::numeric_limits<std::streamsize>::max();
8259 typename CHAR_TRAITS::int_type c1 = buf->sbumpc();
8260 if (CHAR_TRAITS::eq_int_type(c1, CHAR_TRAITS::eof())) {
8261 is.setstate(Istrm::eofbit);
8265 CHAR_TYPE c = CHAR_TRAITS::to_char_type(c1);
8267 if (ctype.is(CType::space, c)) {
8268 if (CHAR_TRAITS::eq_int_type(buf->sputbackc(c),
8269 CHAR_TRAITS::eof())) {
8270 is.setstate(Istrm::failbit);
8282 if (str.size() == 0) {
8283 is.setstate(Istrm::failbit);
8287 is.setstate(Istrm::failbit);
8293template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
8294std::basic_istream<CHAR_TYPE, CHAR_TRAITS>&
8295bsl::getline(std::basic_istream<CHAR_TYPE, CHAR_TRAITS>& is,
8296 basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>& str,
8299 typedef std::basic_istream<CHAR_TYPE, CHAR_TRAITS> Istrm;
8300 std::size_t nread = 0;
8301 typename Istrm::sentry sentry(is,
true);
8303 std::basic_streambuf<CHAR_TYPE, CHAR_TRAITS> *buf = is.rdbuf();
8306 while (nread < str.max_size()) {
8307 int c1 = buf->sbumpc();
8308 if (CHAR_TRAITS::eq_int_type(c1, CHAR_TRAITS::eof())) {
8309 is.setstate(Istrm::eofbit);
8314 CHAR_TYPE c = CHAR_TRAITS::to_char_type(c1);
8315 if (!CHAR_TRAITS::eq(c, delim)) {
8323 if (nread == 0 || nread >= str.max_size()) {
8324 is.setstate(Istrm::failbit);
8330template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
8332std::basic_istream<CHAR_TYPE, CHAR_TRAITS>&
8333bsl::getline(std::basic_istream<CHAR_TYPE, CHAR_TRAITS>& is,
8334 basic_string<CHAR_TYPE,CHAR_TRAITS,ALLOCATOR>& str)
8336 return getline(is, str, is.widen(
'\n'));
8340template <
class HASHALG,
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
8344 const basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>& input)
8346 using ::BloombergLP::bslh::hashAppend;
8347 hashAlg(input.data(),
sizeof(CHAR_TYPE)*input.size());
8351template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
8354 const basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>& str)
8356 return ::BloombergLP::bslh::Hash<>()(str);
8361template <
class HASHALG,
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
8365 const std::basic_string<CHAR_TYPE, CHAR_TRAITS, ALLOCATOR>& input)
8367 hashAlg(input.data(),
sizeof(CHAR_TYPE)*input.size());
8388template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
8397template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOC>
8406#undef BSLSTL_CHAR_TRAITS
8408#ifdef BSLS_COMPILERFEATURES_SUPPORT_EXTERN_TEMPLATE
8414# if defined(BSLS_COMPILERFEATURES_SUPPORT_UTF8_CHAR_TYPE)
8419# if defined(BSLS_COMPILERFEATURES_SUPPORT_UNICODE_CHAR_TYPES)
8428#undef BSLSTL_STRING_SUPPORT_RVALUE_ADDITION_OPERATORS
8430#undef BSLSTL_STRING_DEFINE_STRINGVIEW_LIKE_TYPE_IF_COMPLETE
8431#undef BSLSTL_STRING_DEFINE_ONLY_CONVERTIBLE_TO_STRINGVIEW_RETURN_TYPE
8432#undef BSLSTL_STRING_DECLARE_CONVERTIBLE_TO_STRINGVIEW_PARAM_VOID
8433#undef BSLSTL_STRING_DEFINE_CONVERTIBLE_TO_STRINGVIEW_PARAM_VOID
8434#undef BSLSTL_STRING_DECLARE_ONLY_CONVERTIBLE_TO_STRINGVIEW_PARAM_VOID
8435#undef BSLSTL_STRING_DEFINE_ONLY_CONVERTIBLE_TO_STRINGVIEW_PARAM_VOID
8436#undef BSLSTL_STRING_DECLARE_ONLY_CONVERTIBLE_TO_STRINGVIEW_PARAM_ALLOC
8437#undef BSLSTL_STRING_DEFINE_ONLY_CONVERTIBLE_TO_STRINGVIEW_PARAM_ALLOC
8439#undef BSLSTL_STRING_DEDUCE_RVREF
8440#undef BSLSTL_STRING_DEDUCE_RVREF_1
8441#undef BSLSTL_STRING_DEDUCE_RVREF_2