17a984708SDavid Chisnall// -*- C++ -*- 27a984708SDavid Chisnall//===--------------------------- string -----------------------------------===// 37a984708SDavid Chisnall// 47a984708SDavid Chisnall// The LLVM Compiler Infrastructure 57a984708SDavid Chisnall// 67a984708SDavid Chisnall// This file is distributed under the University of Illinois Open Source 77a984708SDavid Chisnall// License. See LICENSE.TXT for details. 87a984708SDavid Chisnall// 97a984708SDavid Chisnall//===----------------------------------------------------------------------===// 107a984708SDavid Chisnall 117a984708SDavid Chisnall#ifndef _LIBCPP_STRING 127a984708SDavid Chisnall#define _LIBCPP_STRING 137a984708SDavid Chisnall 147a984708SDavid Chisnall/* 157a984708SDavid Chisnall string synopsis 167a984708SDavid Chisnall 177a984708SDavid Chisnallnamespace std 187a984708SDavid Chisnall{ 197a984708SDavid Chisnall 207a984708SDavid Chisnalltemplate <class stateT> 217a984708SDavid Chisnallclass fpos 227a984708SDavid Chisnall{ 237a984708SDavid Chisnallprivate: 247a984708SDavid Chisnall stateT st; 257a984708SDavid Chisnallpublic: 267a984708SDavid Chisnall fpos(streamoff = streamoff()); 277a984708SDavid Chisnall 287a984708SDavid Chisnall operator streamoff() const; 297a984708SDavid Chisnall 307a984708SDavid Chisnall stateT state() const; 317a984708SDavid Chisnall void state(stateT); 327a984708SDavid Chisnall 337a984708SDavid Chisnall fpos& operator+=(streamoff); 347a984708SDavid Chisnall fpos operator+ (streamoff) const; 357a984708SDavid Chisnall fpos& operator-=(streamoff); 367a984708SDavid Chisnall fpos operator- (streamoff) const; 377a984708SDavid Chisnall}; 387a984708SDavid Chisnall 397a984708SDavid Chisnalltemplate <class stateT> streamoff operator-(const fpos<stateT>& x, const fpos<stateT>& y); 407a984708SDavid Chisnall 417a984708SDavid Chisnalltemplate <class stateT> bool operator==(const fpos<stateT>& x, const fpos<stateT>& y); 427a984708SDavid Chisnalltemplate <class stateT> bool operator!=(const fpos<stateT>& x, const fpos<stateT>& y); 437a984708SDavid Chisnall 447a984708SDavid Chisnalltemplate <class charT> 457a984708SDavid Chisnallstruct char_traits 467a984708SDavid Chisnall{ 477a984708SDavid Chisnall typedef charT char_type; 487a984708SDavid Chisnall typedef ... int_type; 497a984708SDavid Chisnall typedef streamoff off_type; 507a984708SDavid Chisnall typedef streampos pos_type; 517a984708SDavid Chisnall typedef mbstate_t state_type; 527a984708SDavid Chisnall 537a984708SDavid Chisnall static void assign(char_type& c1, const char_type& c2) noexcept; 54936e9439SDimitry Andric static constexpr bool eq(char_type c1, char_type c2) noexcept; 55936e9439SDimitry Andric static constexpr bool lt(char_type c1, char_type c2) noexcept; 567a984708SDavid Chisnall 577a984708SDavid Chisnall static int compare(const char_type* s1, const char_type* s2, size_t n); 587a984708SDavid Chisnall static size_t length(const char_type* s); 597a984708SDavid Chisnall static const char_type* find(const char_type* s, size_t n, const char_type& a); 607a984708SDavid Chisnall static char_type* move(char_type* s1, const char_type* s2, size_t n); 617a984708SDavid Chisnall static char_type* copy(char_type* s1, const char_type* s2, size_t n); 627a984708SDavid Chisnall static char_type* assign(char_type* s, size_t n, char_type a); 637a984708SDavid Chisnall 64936e9439SDimitry Andric static constexpr int_type not_eof(int_type c) noexcept; 65936e9439SDimitry Andric static constexpr char_type to_char_type(int_type c) noexcept; 66936e9439SDimitry Andric static constexpr int_type to_int_type(char_type c) noexcept; 67936e9439SDimitry Andric static constexpr bool eq_int_type(int_type c1, int_type c2) noexcept; 68936e9439SDimitry Andric static constexpr int_type eof() noexcept; 697a984708SDavid Chisnall}; 707a984708SDavid Chisnall 717a984708SDavid Chisnalltemplate <> struct char_traits<char>; 727a984708SDavid Chisnalltemplate <> struct char_traits<wchar_t>; 737a984708SDavid Chisnall 747a984708SDavid Chisnalltemplate<class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > 757a984708SDavid Chisnallclass basic_string 767a984708SDavid Chisnall{ 777a984708SDavid Chisnallpublic: 787a984708SDavid Chisnall// types: 797a984708SDavid Chisnall typedef traits traits_type; 807a984708SDavid Chisnall typedef typename traits_type::char_type value_type; 817a984708SDavid Chisnall typedef Allocator allocator_type; 827a984708SDavid Chisnall typedef typename allocator_type::size_type size_type; 837a984708SDavid Chisnall typedef typename allocator_type::difference_type difference_type; 847a984708SDavid Chisnall typedef typename allocator_type::reference reference; 857a984708SDavid Chisnall typedef typename allocator_type::const_reference const_reference; 867a984708SDavid Chisnall typedef typename allocator_type::pointer pointer; 877a984708SDavid Chisnall typedef typename allocator_type::const_pointer const_pointer; 887a984708SDavid Chisnall typedef implementation-defined iterator; 897a984708SDavid Chisnall typedef implementation-defined const_iterator; 907a984708SDavid Chisnall typedef std::reverse_iterator<iterator> reverse_iterator; 917a984708SDavid Chisnall typedef std::reverse_iterator<const_iterator> const_reverse_iterator; 927a984708SDavid Chisnall 937a984708SDavid Chisnall static const size_type npos = -1; 947a984708SDavid Chisnall 957a984708SDavid Chisnall basic_string() 967a984708SDavid Chisnall noexcept(is_nothrow_default_constructible<allocator_type>::value); 977a984708SDavid Chisnall explicit basic_string(const allocator_type& a); 987a984708SDavid Chisnall basic_string(const basic_string& str); 997a984708SDavid Chisnall basic_string(basic_string&& str) 1007a984708SDavid Chisnall noexcept(is_nothrow_move_constructible<allocator_type>::value); 1017c82a1ecSDimitry Andric basic_string(const basic_string& str, size_type pos, 1027a984708SDavid Chisnall const allocator_type& a = allocator_type()); 1037c82a1ecSDimitry Andric basic_string(const basic_string& str, size_type pos, size_type n, 1047c82a1ecSDimitry Andric const Allocator& a = Allocator()); 105aed8d94eSDimitry Andric template<class T> 106aed8d94eSDimitry Andric basic_string(const T& t, size_type pos, size_type n, const Allocator& a = Allocator()); // C++17 1074ba319b5SDimitry Andric template <class T> 1084ba319b5SDimitry Andric explicit basic_string(const T& t, const Allocator& a = Allocator()); // C++17 1094bab9fd9SDavid Chisnall basic_string(const value_type* s, const allocator_type& a = allocator_type()); 1104bab9fd9SDavid Chisnall basic_string(const value_type* s, size_type n, const allocator_type& a = allocator_type()); 1117a984708SDavid Chisnall basic_string(size_type n, value_type c, const allocator_type& a = allocator_type()); 1127a984708SDavid Chisnall template<class InputIterator> 1137a984708SDavid Chisnall basic_string(InputIterator begin, InputIterator end, 1147a984708SDavid Chisnall const allocator_type& a = allocator_type()); 1157a984708SDavid Chisnall basic_string(initializer_list<value_type>, const Allocator& = Allocator()); 1167a984708SDavid Chisnall basic_string(const basic_string&, const Allocator&); 1177a984708SDavid Chisnall basic_string(basic_string&&, const Allocator&); 1187a984708SDavid Chisnall 1197a984708SDavid Chisnall ~basic_string(); 1207a984708SDavid Chisnall 121aed8d94eSDimitry Andric operator basic_string_view<charT, traits>() const noexcept; 122aed8d94eSDimitry Andric 1237a984708SDavid Chisnall basic_string& operator=(const basic_string& str); 1244ba319b5SDimitry Andric template <class T> 1254ba319b5SDimitry Andric basic_string& operator=(const T& t); // C++17 1267a984708SDavid Chisnall basic_string& operator=(basic_string&& str) 1277a984708SDavid Chisnall noexcept( 1289729cf09SDimitry Andric allocator_type::propagate_on_container_move_assignment::value || 1299729cf09SDimitry Andric allocator_type::is_always_equal::value ); // C++17 1304bab9fd9SDavid Chisnall basic_string& operator=(const value_type* s); 1317a984708SDavid Chisnall basic_string& operator=(value_type c); 1327a984708SDavid Chisnall basic_string& operator=(initializer_list<value_type>); 1337a984708SDavid Chisnall 1347a984708SDavid Chisnall iterator begin() noexcept; 1357a984708SDavid Chisnall const_iterator begin() const noexcept; 1367a984708SDavid Chisnall iterator end() noexcept; 1377a984708SDavid Chisnall const_iterator end() const noexcept; 1387a984708SDavid Chisnall 1397a984708SDavid Chisnall reverse_iterator rbegin() noexcept; 1407a984708SDavid Chisnall const_reverse_iterator rbegin() const noexcept; 1417a984708SDavid Chisnall reverse_iterator rend() noexcept; 1427a984708SDavid Chisnall const_reverse_iterator rend() const noexcept; 1437a984708SDavid Chisnall 1447a984708SDavid Chisnall const_iterator cbegin() const noexcept; 1457a984708SDavid Chisnall const_iterator cend() const noexcept; 1467a984708SDavid Chisnall const_reverse_iterator crbegin() const noexcept; 1477a984708SDavid Chisnall const_reverse_iterator crend() const noexcept; 1487a984708SDavid Chisnall 1497a984708SDavid Chisnall size_type size() const noexcept; 1507a984708SDavid Chisnall size_type length() const noexcept; 1517a984708SDavid Chisnall size_type max_size() const noexcept; 1527a984708SDavid Chisnall size_type capacity() const noexcept; 1537a984708SDavid Chisnall 1547a984708SDavid Chisnall void resize(size_type n, value_type c); 1557a984708SDavid Chisnall void resize(size_type n); 1567a984708SDavid Chisnall 1577a984708SDavid Chisnall void reserve(size_type res_arg = 0); 1587a984708SDavid Chisnall void shrink_to_fit(); 1597a984708SDavid Chisnall void clear() noexcept; 1607a984708SDavid Chisnall bool empty() const noexcept; 1617a984708SDavid Chisnall 1627a984708SDavid Chisnall const_reference operator[](size_type pos) const; 1637a984708SDavid Chisnall reference operator[](size_type pos); 1647a984708SDavid Chisnall 1657a984708SDavid Chisnall const_reference at(size_type n) const; 1667a984708SDavid Chisnall reference at(size_type n); 1677a984708SDavid Chisnall 1687a984708SDavid Chisnall basic_string& operator+=(const basic_string& str); 1694ba319b5SDimitry Andric template <class T> 1704ba319b5SDimitry Andric basic_string& operator+=(const T& t); // C++17 1714bab9fd9SDavid Chisnall basic_string& operator+=(const value_type* s); 1727a984708SDavid Chisnall basic_string& operator+=(value_type c); 1737a984708SDavid Chisnall basic_string& operator+=(initializer_list<value_type>); 1747a984708SDavid Chisnall 1757a984708SDavid Chisnall basic_string& append(const basic_string& str); 1764ba319b5SDimitry Andric template <class T> 1774ba319b5SDimitry Andric basic_string& append(const T& t); // C++17 178d72607e9SDimitry Andric basic_string& append(const basic_string& str, size_type pos, size_type n=npos); //C++14 179aed8d94eSDimitry Andric template <class T> 180aed8d94eSDimitry Andric basic_string& append(const T& t, size_type pos, size_type n=npos); // C++17 1814bab9fd9SDavid Chisnall basic_string& append(const value_type* s, size_type n); 1824bab9fd9SDavid Chisnall basic_string& append(const value_type* s); 1837a984708SDavid Chisnall basic_string& append(size_type n, value_type c); 1847a984708SDavid Chisnall template<class InputIterator> 1857a984708SDavid Chisnall basic_string& append(InputIterator first, InputIterator last); 1867a984708SDavid Chisnall basic_string& append(initializer_list<value_type>); 1877a984708SDavid Chisnall 1887a984708SDavid Chisnall void push_back(value_type c); 1897a984708SDavid Chisnall void pop_back(); 1907a984708SDavid Chisnall reference front(); 1917a984708SDavid Chisnall const_reference front() const; 1927a984708SDavid Chisnall reference back(); 1937a984708SDavid Chisnall const_reference back() const; 1947a984708SDavid Chisnall 1957a984708SDavid Chisnall basic_string& assign(const basic_string& str); 1964ba319b5SDimitry Andric template <class T> 1974ba319b5SDimitry Andric basic_string& assign(const T& t); // C++17 1987a984708SDavid Chisnall basic_string& assign(basic_string&& str); 199d72607e9SDimitry Andric basic_string& assign(const basic_string& str, size_type pos, size_type n=npos); // C++14 200aed8d94eSDimitry Andric template <class T> 201aed8d94eSDimitry Andric basic_string& assign(const T& t, size_type pos, size_type n=npos); // C++17 2024bab9fd9SDavid Chisnall basic_string& assign(const value_type* s, size_type n); 2034bab9fd9SDavid Chisnall basic_string& assign(const value_type* s); 2047a984708SDavid Chisnall basic_string& assign(size_type n, value_type c); 2057a984708SDavid Chisnall template<class InputIterator> 2067a984708SDavid Chisnall basic_string& assign(InputIterator first, InputIterator last); 2077a984708SDavid Chisnall basic_string& assign(initializer_list<value_type>); 2087a984708SDavid Chisnall 2097a984708SDavid Chisnall basic_string& insert(size_type pos1, const basic_string& str); 2104ba319b5SDimitry Andric template <class T> 2114ba319b5SDimitry Andric basic_string& insert(size_type pos1, const T& t); 2127a984708SDavid Chisnall basic_string& insert(size_type pos1, const basic_string& str, 2137a984708SDavid Chisnall size_type pos2, size_type n); 214aed8d94eSDimitry Andric template <class T> 215aed8d94eSDimitry Andric basic_string& insert(size_type pos1, const T& t, size_type pos2, size_type n); // C++17 216d72607e9SDimitry Andric basic_string& insert(size_type pos, const value_type* s, size_type n=npos); //C++14 2174bab9fd9SDavid Chisnall basic_string& insert(size_type pos, const value_type* s); 2187a984708SDavid Chisnall basic_string& insert(size_type pos, size_type n, value_type c); 2197a984708SDavid Chisnall iterator insert(const_iterator p, value_type c); 2207a984708SDavid Chisnall iterator insert(const_iterator p, size_type n, value_type c); 2217a984708SDavid Chisnall template<class InputIterator> 2227a984708SDavid Chisnall iterator insert(const_iterator p, InputIterator first, InputIterator last); 2237a984708SDavid Chisnall iterator insert(const_iterator p, initializer_list<value_type>); 2247a984708SDavid Chisnall 2257a984708SDavid Chisnall basic_string& erase(size_type pos = 0, size_type n = npos); 2267a984708SDavid Chisnall iterator erase(const_iterator position); 2277a984708SDavid Chisnall iterator erase(const_iterator first, const_iterator last); 2287a984708SDavid Chisnall 2297a984708SDavid Chisnall basic_string& replace(size_type pos1, size_type n1, const basic_string& str); 2304ba319b5SDimitry Andric template <class T> 2314ba319b5SDimitry Andric basic_string& replace(size_type pos1, size_type n1, const T& t); // C++17 2327a984708SDavid Chisnall basic_string& replace(size_type pos1, size_type n1, const basic_string& str, 233d72607e9SDimitry Andric size_type pos2, size_type n2=npos); // C++14 234aed8d94eSDimitry Andric template <class T> 235aed8d94eSDimitry Andric basic_string& replace(size_type pos1, size_type n1, const T& t, 236aed8d94eSDimitry Andric size_type pos2, size_type n); // C++17 2374bab9fd9SDavid Chisnall basic_string& replace(size_type pos, size_type n1, const value_type* s, size_type n2); 2384bab9fd9SDavid Chisnall basic_string& replace(size_type pos, size_type n1, const value_type* s); 2397a984708SDavid Chisnall basic_string& replace(size_type pos, size_type n1, size_type n2, value_type c); 2407a984708SDavid Chisnall basic_string& replace(const_iterator i1, const_iterator i2, const basic_string& str); 2414ba319b5SDimitry Andric template <class T> 2424ba319b5SDimitry Andric basic_string& replace(const_iterator i1, const_iterator i2, const T& t); // C++17 2434bab9fd9SDavid Chisnall basic_string& replace(const_iterator i1, const_iterator i2, const value_type* s, size_type n); 2444bab9fd9SDavid Chisnall basic_string& replace(const_iterator i1, const_iterator i2, const value_type* s); 2457a984708SDavid Chisnall basic_string& replace(const_iterator i1, const_iterator i2, size_type n, value_type c); 2467a984708SDavid Chisnall template<class InputIterator> 2477a984708SDavid Chisnall basic_string& replace(const_iterator i1, const_iterator i2, InputIterator j1, InputIterator j2); 2487a984708SDavid Chisnall basic_string& replace(const_iterator i1, const_iterator i2, initializer_list<value_type>); 2497a984708SDavid Chisnall 2504bab9fd9SDavid Chisnall size_type copy(value_type* s, size_type n, size_type pos = 0) const; 2517a984708SDavid Chisnall basic_string substr(size_type pos = 0, size_type n = npos) const; 2527a984708SDavid Chisnall 2537a984708SDavid Chisnall void swap(basic_string& str) 254854fa44bSDimitry Andric noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value || 255854fa44bSDimitry Andric allocator_traits<allocator_type>::is_always_equal::value); // C++17 2567a984708SDavid Chisnall 2574bab9fd9SDavid Chisnall const value_type* c_str() const noexcept; 2584bab9fd9SDavid Chisnall const value_type* data() const noexcept; 2597c82a1ecSDimitry Andric value_type* data() noexcept; // C++17 2607a984708SDavid Chisnall 2617a984708SDavid Chisnall allocator_type get_allocator() const noexcept; 2627a984708SDavid Chisnall 2637a984708SDavid Chisnall size_type find(const basic_string& str, size_type pos = 0) const noexcept; 2644ba319b5SDimitry Andric template <class T> 2654ba319b5SDimitry Andric size_type find(const T& t, size_type pos = 0) const; // C++17 2664bab9fd9SDavid Chisnall size_type find(const value_type* s, size_type pos, size_type n) const noexcept; 2674bab9fd9SDavid Chisnall size_type find(const value_type* s, size_type pos = 0) const noexcept; 2687a984708SDavid Chisnall size_type find(value_type c, size_type pos = 0) const noexcept; 2697a984708SDavid Chisnall 2707a984708SDavid Chisnall size_type rfind(const basic_string& str, size_type pos = npos) const noexcept; 2714ba319b5SDimitry Andric template <class T> 2724ba319b5SDimitry Andric size_type rfind(const T& t, size_type pos = npos) const; // C++17 2734bab9fd9SDavid Chisnall size_type rfind(const value_type* s, size_type pos, size_type n) const noexcept; 2744bab9fd9SDavid Chisnall size_type rfind(const value_type* s, size_type pos = npos) const noexcept; 2757a984708SDavid Chisnall size_type rfind(value_type c, size_type pos = npos) const noexcept; 2767a984708SDavid Chisnall 2777a984708SDavid Chisnall size_type find_first_of(const basic_string& str, size_type pos = 0) const noexcept; 2784ba319b5SDimitry Andric template <class T> 2794ba319b5SDimitry Andric size_type find_first_of(const T& t, size_type pos = 0) const; // C++17 2804bab9fd9SDavid Chisnall size_type find_first_of(const value_type* s, size_type pos, size_type n) const noexcept; 2814bab9fd9SDavid Chisnall size_type find_first_of(const value_type* s, size_type pos = 0) const noexcept; 2827a984708SDavid Chisnall size_type find_first_of(value_type c, size_type pos = 0) const noexcept; 2837a984708SDavid Chisnall 2847a984708SDavid Chisnall size_type find_last_of(const basic_string& str, size_type pos = npos) const noexcept; 2854ba319b5SDimitry Andric template <class T> 2864ba319b5SDimitry Andric size_type find_last_of(const T& t, size_type pos = npos) const noexcept; // C++17 2874bab9fd9SDavid Chisnall size_type find_last_of(const value_type* s, size_type pos, size_type n) const noexcept; 2884bab9fd9SDavid Chisnall size_type find_last_of(const value_type* s, size_type pos = npos) const noexcept; 2897a984708SDavid Chisnall size_type find_last_of(value_type c, size_type pos = npos) const noexcept; 2907a984708SDavid Chisnall 2917a984708SDavid Chisnall size_type find_first_not_of(const basic_string& str, size_type pos = 0) const noexcept; 2924ba319b5SDimitry Andric template <class T> 2934ba319b5SDimitry Andric size_type find_first_not_of(const T& t, size_type pos = 0) const; // C++17 2944bab9fd9SDavid Chisnall size_type find_first_not_of(const value_type* s, size_type pos, size_type n) const noexcept; 2954bab9fd9SDavid Chisnall size_type find_first_not_of(const value_type* s, size_type pos = 0) const noexcept; 2967a984708SDavid Chisnall size_type find_first_not_of(value_type c, size_type pos = 0) const noexcept; 2977a984708SDavid Chisnall 2987a984708SDavid Chisnall size_type find_last_not_of(const basic_string& str, size_type pos = npos) const noexcept; 2994ba319b5SDimitry Andric template <class T> 3004ba319b5SDimitry Andric size_type find_last_not_of(const T& t, size_type pos = npos) const; // C++17 3014bab9fd9SDavid Chisnall size_type find_last_not_of(const value_type* s, size_type pos, size_type n) const noexcept; 3024bab9fd9SDavid Chisnall size_type find_last_not_of(const value_type* s, size_type pos = npos) const noexcept; 3037a984708SDavid Chisnall size_type find_last_not_of(value_type c, size_type pos = npos) const noexcept; 3047a984708SDavid Chisnall 3057a984708SDavid Chisnall int compare(const basic_string& str) const noexcept; 3064ba319b5SDimitry Andric template <class T> 3074ba319b5SDimitry Andric int compare(const T& t) const noexcept; // C++17 3087a984708SDavid Chisnall int compare(size_type pos1, size_type n1, const basic_string& str) const; 3094ba319b5SDimitry Andric template <class T> 3104ba319b5SDimitry Andric int compare(size_type pos1, size_type n1, const T& t) const; // C++17 3117a984708SDavid Chisnall int compare(size_type pos1, size_type n1, const basic_string& str, 312d72607e9SDimitry Andric size_type pos2, size_type n2=npos) const; // C++14 313aed8d94eSDimitry Andric template <class T> 314aed8d94eSDimitry Andric int compare(size_type pos1, size_type n1, const T& t, 315aed8d94eSDimitry Andric size_type pos2, size_type n2=npos) const; // C++17 3164bab9fd9SDavid Chisnall int compare(const value_type* s) const noexcept; 3174bab9fd9SDavid Chisnall int compare(size_type pos1, size_type n1, const value_type* s) const; 3184bab9fd9SDavid Chisnall int compare(size_type pos1, size_type n1, const value_type* s, size_type n2) const; 3197a984708SDavid Chisnall 320b2c7081bSDimitry Andric bool starts_with(basic_string_view<charT, traits> sv) const noexcept; // C++2a 321b2c7081bSDimitry Andric bool starts_with(charT c) const noexcept; // C++2a 322b2c7081bSDimitry Andric bool starts_with(const charT* s) const; // C++2a 323b2c7081bSDimitry Andric bool ends_with(basic_string_view<charT, traits> sv) const noexcept; // C++2a 324b2c7081bSDimitry Andric bool ends_with(charT c) const noexcept; // C++2a 325b2c7081bSDimitry Andric bool ends_with(const charT* s) const; // C++2a 326b2c7081bSDimitry Andric 3277a984708SDavid Chisnall bool __invariants() const; 3287a984708SDavid Chisnall}; 3297a984708SDavid Chisnall 3304ba319b5SDimitry Andrictemplate<class InputIterator, 3314ba319b5SDimitry Andric class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>> 3324ba319b5SDimitry Andricbasic_string(InputIterator, InputIterator, Allocator = Allocator()) 3334ba319b5SDimitry Andric -> basic_string<typename iterator_traits<InputIterator>::value_type, 3344ba319b5SDimitry Andric char_traits<typename iterator_traits<InputIterator>::value_type>, 3354ba319b5SDimitry Andric Allocator>; // C++17 3364ba319b5SDimitry Andric 3377a984708SDavid Chisnalltemplate<class charT, class traits, class Allocator> 3387a984708SDavid Chisnallbasic_string<charT, traits, Allocator> 3397a984708SDavid Chisnalloperator+(const basic_string<charT, traits, Allocator>& lhs, 3407a984708SDavid Chisnall const basic_string<charT, traits, Allocator>& rhs); 3417a984708SDavid Chisnall 3427a984708SDavid Chisnalltemplate<class charT, class traits, class Allocator> 3437a984708SDavid Chisnallbasic_string<charT, traits, Allocator> 3447a984708SDavid Chisnalloperator+(const charT* lhs , const basic_string<charT,traits,Allocator>&rhs); 3457a984708SDavid Chisnall 3467a984708SDavid Chisnalltemplate<class charT, class traits, class Allocator> 3477a984708SDavid Chisnallbasic_string<charT, traits, Allocator> 3487a984708SDavid Chisnalloperator+(charT lhs, const basic_string<charT,traits,Allocator>& rhs); 3497a984708SDavid Chisnall 3507a984708SDavid Chisnalltemplate<class charT, class traits, class Allocator> 3517a984708SDavid Chisnallbasic_string<charT, traits, Allocator> 3527a984708SDavid Chisnalloperator+(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs); 3537a984708SDavid Chisnall 3547a984708SDavid Chisnalltemplate<class charT, class traits, class Allocator> 3557a984708SDavid Chisnallbasic_string<charT, traits, Allocator> 3567a984708SDavid Chisnalloperator+(const basic_string<charT, traits, Allocator>& lhs, charT rhs); 3577a984708SDavid Chisnall 3587a984708SDavid Chisnalltemplate<class charT, class traits, class Allocator> 3597a984708SDavid Chisnallbool operator==(const basic_string<charT, traits, Allocator>& lhs, 3607a984708SDavid Chisnall const basic_string<charT, traits, Allocator>& rhs) noexcept; 3617a984708SDavid Chisnall 3627a984708SDavid Chisnalltemplate<class charT, class traits, class Allocator> 3637a984708SDavid Chisnallbool operator==(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; 3647a984708SDavid Chisnall 3657a984708SDavid Chisnalltemplate<class charT, class traits, class Allocator> 3667a984708SDavid Chisnallbool operator==(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs) noexcept; 3677a984708SDavid Chisnall 3687a984708SDavid Chisnalltemplate<class charT, class traits, class Allocator> 3697a984708SDavid Chisnallbool operator!=(const basic_string<charT,traits,Allocator>& lhs, 3707a984708SDavid Chisnall const basic_string<charT, traits, Allocator>& rhs) noexcept; 3717a984708SDavid Chisnall 3727a984708SDavid Chisnalltemplate<class charT, class traits, class Allocator> 3737a984708SDavid Chisnallbool operator!=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; 3747a984708SDavid Chisnall 3757a984708SDavid Chisnalltemplate<class charT, class traits, class Allocator> 3767a984708SDavid Chisnallbool operator!=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; 3777a984708SDavid Chisnall 3787a984708SDavid Chisnalltemplate<class charT, class traits, class Allocator> 3797a984708SDavid Chisnallbool operator< (const basic_string<charT, traits, Allocator>& lhs, 3807a984708SDavid Chisnall const basic_string<charT, traits, Allocator>& rhs) noexcept; 3817a984708SDavid Chisnall 3827a984708SDavid Chisnalltemplate<class charT, class traits, class Allocator> 3837a984708SDavid Chisnallbool operator< (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; 3847a984708SDavid Chisnall 3857a984708SDavid Chisnalltemplate<class charT, class traits, class Allocator> 3867a984708SDavid Chisnallbool operator< (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; 3877a984708SDavid Chisnall 3887a984708SDavid Chisnalltemplate<class charT, class traits, class Allocator> 3897a984708SDavid Chisnallbool operator> (const basic_string<charT, traits, Allocator>& lhs, 3907a984708SDavid Chisnall const basic_string<charT, traits, Allocator>& rhs) noexcept; 3917a984708SDavid Chisnall 3927a984708SDavid Chisnalltemplate<class charT, class traits, class Allocator> 3937a984708SDavid Chisnallbool operator> (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; 3947a984708SDavid Chisnall 3957a984708SDavid Chisnalltemplate<class charT, class traits, class Allocator> 3967a984708SDavid Chisnallbool operator> (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; 3977a984708SDavid Chisnall 3987a984708SDavid Chisnalltemplate<class charT, class traits, class Allocator> 3997a984708SDavid Chisnallbool operator<=(const basic_string<charT, traits, Allocator>& lhs, 4007a984708SDavid Chisnall const basic_string<charT, traits, Allocator>& rhs) noexcept; 4017a984708SDavid Chisnall 4027a984708SDavid Chisnalltemplate<class charT, class traits, class Allocator> 4037a984708SDavid Chisnallbool operator<=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; 4047a984708SDavid Chisnall 4057a984708SDavid Chisnalltemplate<class charT, class traits, class Allocator> 4067a984708SDavid Chisnallbool operator<=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; 4077a984708SDavid Chisnall 4087a984708SDavid Chisnalltemplate<class charT, class traits, class Allocator> 4097a984708SDavid Chisnallbool operator>=(const basic_string<charT, traits, Allocator>& lhs, 4107a984708SDavid Chisnall const basic_string<charT, traits, Allocator>& rhs) noexcept; 4117a984708SDavid Chisnall 4127a984708SDavid Chisnalltemplate<class charT, class traits, class Allocator> 4137a984708SDavid Chisnallbool operator>=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; 4147a984708SDavid Chisnall 4157a984708SDavid Chisnalltemplate<class charT, class traits, class Allocator> 4167a984708SDavid Chisnallbool operator>=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; 4177a984708SDavid Chisnall 4187a984708SDavid Chisnalltemplate<class charT, class traits, class Allocator> 4197a984708SDavid Chisnallvoid swap(basic_string<charT, traits, Allocator>& lhs, 4207a984708SDavid Chisnall basic_string<charT, traits, Allocator>& rhs) 4217a984708SDavid Chisnall noexcept(noexcept(lhs.swap(rhs))); 4227a984708SDavid Chisnall 4237a984708SDavid Chisnalltemplate<class charT, class traits, class Allocator> 4247a984708SDavid Chisnallbasic_istream<charT, traits>& 4257a984708SDavid Chisnalloperator>>(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str); 4267a984708SDavid Chisnall 4277a984708SDavid Chisnalltemplate<class charT, class traits, class Allocator> 4287a984708SDavid Chisnallbasic_ostream<charT, traits>& 4297a984708SDavid Chisnalloperator<<(basic_ostream<charT, traits>& os, const basic_string<charT, traits, Allocator>& str); 4307a984708SDavid Chisnall 4317a984708SDavid Chisnalltemplate<class charT, class traits, class Allocator> 4327a984708SDavid Chisnallbasic_istream<charT, traits>& 4337a984708SDavid Chisnallgetline(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str, 4347a984708SDavid Chisnall charT delim); 4357a984708SDavid Chisnall 4367a984708SDavid Chisnalltemplate<class charT, class traits, class Allocator> 4377a984708SDavid Chisnallbasic_istream<charT, traits>& 4387a984708SDavid Chisnallgetline(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str); 4397a984708SDavid Chisnall 440*b5893f02SDimitry Andrictemplate<class charT, class traits, class Allocator, class U> 441*b5893f02SDimitry Andricvoid erase(basic_string<charT, traits, Allocator>& c, const U& value); // C++20 442*b5893f02SDimitry Andrictemplate<class charT, class traits, class Allocator, class Predicate> 443*b5893f02SDimitry Andricvoid erase_if(basic_string<charT, traits, Allocator>& c, Predicate pred); // C++20 444*b5893f02SDimitry Andric 4457a984708SDavid Chisnalltypedef basic_string<char> string; 4467a984708SDavid Chisnalltypedef basic_string<wchar_t> wstring; 4477a984708SDavid Chisnalltypedef basic_string<char16_t> u16string; 4487a984708SDavid Chisnalltypedef basic_string<char32_t> u32string; 4497a984708SDavid Chisnall 4507a984708SDavid Chisnallint stoi (const string& str, size_t* idx = 0, int base = 10); 4517a984708SDavid Chisnalllong stol (const string& str, size_t* idx = 0, int base = 10); 4527a984708SDavid Chisnallunsigned long stoul (const string& str, size_t* idx = 0, int base = 10); 4537a984708SDavid Chisnalllong long stoll (const string& str, size_t* idx = 0, int base = 10); 4547a984708SDavid Chisnallunsigned long long stoull(const string& str, size_t* idx = 0, int base = 10); 4557a984708SDavid Chisnall 4567a984708SDavid Chisnallfloat stof (const string& str, size_t* idx = 0); 4577a984708SDavid Chisnalldouble stod (const string& str, size_t* idx = 0); 4587a984708SDavid Chisnalllong double stold(const string& str, size_t* idx = 0); 4597a984708SDavid Chisnall 4607a984708SDavid Chisnallstring to_string(int val); 4617a984708SDavid Chisnallstring to_string(unsigned val); 4627a984708SDavid Chisnallstring to_string(long val); 4637a984708SDavid Chisnallstring to_string(unsigned long val); 4647a984708SDavid Chisnallstring to_string(long long val); 4657a984708SDavid Chisnallstring to_string(unsigned long long val); 4667a984708SDavid Chisnallstring to_string(float val); 4677a984708SDavid Chisnallstring to_string(double val); 4687a984708SDavid Chisnallstring to_string(long double val); 4697a984708SDavid Chisnall 4707a984708SDavid Chisnallint stoi (const wstring& str, size_t* idx = 0, int base = 10); 4717a984708SDavid Chisnalllong stol (const wstring& str, size_t* idx = 0, int base = 10); 4727a984708SDavid Chisnallunsigned long stoul (const wstring& str, size_t* idx = 0, int base = 10); 4737a984708SDavid Chisnalllong long stoll (const wstring& str, size_t* idx = 0, int base = 10); 4747a984708SDavid Chisnallunsigned long long stoull(const wstring& str, size_t* idx = 0, int base = 10); 4757a984708SDavid Chisnall 4767a984708SDavid Chisnallfloat stof (const wstring& str, size_t* idx = 0); 4777a984708SDavid Chisnalldouble stod (const wstring& str, size_t* idx = 0); 4787a984708SDavid Chisnalllong double stold(const wstring& str, size_t* idx = 0); 4797a984708SDavid Chisnall 4807a984708SDavid Chisnallwstring to_wstring(int val); 4817a984708SDavid Chisnallwstring to_wstring(unsigned val); 4827a984708SDavid Chisnallwstring to_wstring(long val); 4837a984708SDavid Chisnallwstring to_wstring(unsigned long val); 4847a984708SDavid Chisnallwstring to_wstring(long long val); 4857a984708SDavid Chisnallwstring to_wstring(unsigned long long val); 4867a984708SDavid Chisnallwstring to_wstring(float val); 4877a984708SDavid Chisnallwstring to_wstring(double val); 4887a984708SDavid Chisnallwstring to_wstring(long double val); 4897a984708SDavid Chisnall 4907a984708SDavid Chisnalltemplate <> struct hash<string>; 4917a984708SDavid Chisnalltemplate <> struct hash<u16string>; 4927a984708SDavid Chisnalltemplate <> struct hash<u32string>; 4937a984708SDavid Chisnalltemplate <> struct hash<wstring>; 4947a984708SDavid Chisnall 4954f7ab58eSDimitry Andricbasic_string<char> operator "" s( const char *str, size_t len ); // C++14 4964f7ab58eSDimitry Andricbasic_string<wchar_t> operator "" s( const wchar_t *str, size_t len ); // C++14 4974f7ab58eSDimitry Andricbasic_string<char16_t> operator "" s( const char16_t *str, size_t len ); // C++14 4984f7ab58eSDimitry Andricbasic_string<char32_t> operator "" s( const char32_t *str, size_t len ); // C++14 4994f7ab58eSDimitry Andric 5007a984708SDavid Chisnall} // std 5017a984708SDavid Chisnall 5027a984708SDavid Chisnall*/ 5037a984708SDavid Chisnall 5047a984708SDavid Chisnall#include <__config> 505aed8d94eSDimitry Andric#include <string_view> 5067a984708SDavid Chisnall#include <iosfwd> 5077a984708SDavid Chisnall#include <cstring> 5087a984708SDavid Chisnall#include <cstdio> // For EOF. 5097a984708SDavid Chisnall#include <cwchar> 5107a984708SDavid Chisnall#include <algorithm> 5117a984708SDavid Chisnall#include <iterator> 5127a984708SDavid Chisnall#include <utility> 5137a984708SDavid Chisnall#include <memory> 5147a984708SDavid Chisnall#include <stdexcept> 5157a984708SDavid Chisnall#include <type_traits> 5167a984708SDavid Chisnall#include <initializer_list> 5177a984708SDavid Chisnall#include <__functional_base> 518*b5893f02SDimitry Andric#include <version> 5197a984708SDavid Chisnall#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS 5207a984708SDavid Chisnall#include <cstdint> 5217a984708SDavid Chisnall#endif 5227a984708SDavid Chisnall 523d72607e9SDimitry Andric#include <__debug> 524d72607e9SDimitry Andric 5257a984708SDavid Chisnall#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 5267a984708SDavid Chisnall#pragma GCC system_header 5277a984708SDavid Chisnall#endif 5287a984708SDavid Chisnall 529f9448bf3SDimitry Andric_LIBCPP_PUSH_MACROS 530f9448bf3SDimitry Andric#include <__undef_macros> 531f9448bf3SDimitry Andric 532f9448bf3SDimitry Andric 5337a984708SDavid Chisnall_LIBCPP_BEGIN_NAMESPACE_STD 5347a984708SDavid Chisnall 5357a984708SDavid Chisnall// fpos 5367a984708SDavid Chisnall 5377a984708SDavid Chisnalltemplate <class _StateT> 538aed8d94eSDimitry Andricclass _LIBCPP_TEMPLATE_VIS fpos 5397a984708SDavid Chisnall{ 5407a984708SDavid Chisnallprivate: 5417a984708SDavid Chisnall _StateT __st_; 5427a984708SDavid Chisnall streamoff __off_; 5437a984708SDavid Chisnallpublic: 5447a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY fpos(streamoff __off = streamoff()) : __st_(), __off_(__off) {} 5457a984708SDavid Chisnall 5467a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY operator streamoff() const {return __off_;} 5477a984708SDavid Chisnall 5487a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY _StateT state() const {return __st_;} 5497a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY void state(_StateT __st) {__st_ = __st;} 5507a984708SDavid Chisnall 5517a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY fpos& operator+=(streamoff __off) {__off_ += __off; return *this;} 5527a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY fpos operator+ (streamoff __off) const {fpos __t(*this); __t += __off; return __t;} 5537a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY fpos& operator-=(streamoff __off) {__off_ -= __off; return *this;} 5547a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY fpos operator- (streamoff __off) const {fpos __t(*this); __t -= __off; return __t;} 5557a984708SDavid Chisnall}; 5567a984708SDavid Chisnall 5577a984708SDavid Chisnalltemplate <class _StateT> 5587a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 5597a984708SDavid Chisnallstreamoff operator-(const fpos<_StateT>& __x, const fpos<_StateT>& __y) 5607a984708SDavid Chisnall {return streamoff(__x) - streamoff(__y);} 5617a984708SDavid Chisnall 5627a984708SDavid Chisnalltemplate <class _StateT> 5637a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 5647a984708SDavid Chisnallbool operator==(const fpos<_StateT>& __x, const fpos<_StateT>& __y) 5657a984708SDavid Chisnall {return streamoff(__x) == streamoff(__y);} 5667a984708SDavid Chisnall 5677a984708SDavid Chisnalltemplate <class _StateT> 5687a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 5697a984708SDavid Chisnallbool operator!=(const fpos<_StateT>& __x, const fpos<_StateT>& __y) 5707a984708SDavid Chisnall {return streamoff(__x) != streamoff(__y);} 5717a984708SDavid Chisnall 5727a984708SDavid Chisnall// basic_string 5737a984708SDavid Chisnall 5747a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 5757a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator> 5767a984708SDavid Chisnalloperator+(const basic_string<_CharT, _Traits, _Allocator>& __x, 5777a984708SDavid Chisnall const basic_string<_CharT, _Traits, _Allocator>& __y); 5787a984708SDavid Chisnall 5797a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 5807a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator> 5817a984708SDavid Chisnalloperator+(const _CharT* __x, const basic_string<_CharT,_Traits,_Allocator>& __y); 5827a984708SDavid Chisnall 5837a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 5847a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator> 5857a984708SDavid Chisnalloperator+(_CharT __x, const basic_string<_CharT,_Traits,_Allocator>& __y); 5867a984708SDavid Chisnall 5877a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 588*b5893f02SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 5897a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator> 5907a984708SDavid Chisnalloperator+(const basic_string<_CharT, _Traits, _Allocator>& __x, const _CharT* __y); 5917a984708SDavid Chisnall 5927a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 5937a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator> 5947a984708SDavid Chisnalloperator+(const basic_string<_CharT, _Traits, _Allocator>& __x, _CharT __y); 5957a984708SDavid Chisnall 5960554abf0SDimitry Andric_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS string operator+<char, char_traits<char>, allocator<char> >(char const*, string const&)) 5970554abf0SDimitry Andric 5987a984708SDavid Chisnalltemplate <bool> 599aed8d94eSDimitry Andricclass _LIBCPP_TEMPLATE_VIS __basic_string_common 6007a984708SDavid Chisnall{ 6017a984708SDavid Chisnallprotected: 602aed8d94eSDimitry Andric _LIBCPP_NORETURN void __throw_length_error() const; 603aed8d94eSDimitry Andric _LIBCPP_NORETURN void __throw_out_of_range() const; 6047a984708SDavid Chisnall}; 6057a984708SDavid Chisnall 6067a984708SDavid Chisnalltemplate <bool __b> 6077a984708SDavid Chisnallvoid 6087a984708SDavid Chisnall__basic_string_common<__b>::__throw_length_error() const 6097a984708SDavid Chisnall{ 610aed8d94eSDimitry Andric _VSTD::__throw_length_error("basic_string"); 6117a984708SDavid Chisnall} 6127a984708SDavid Chisnall 6137a984708SDavid Chisnalltemplate <bool __b> 6147a984708SDavid Chisnallvoid 6157a984708SDavid Chisnall__basic_string_common<__b>::__throw_out_of_range() const 6167a984708SDavid Chisnall{ 617aed8d94eSDimitry Andric _VSTD::__throw_out_of_range("basic_string"); 6187a984708SDavid Chisnall} 6197a984708SDavid Chisnall 620aed8d94eSDimitry Andric_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __basic_string_common<true>) 6217a984708SDavid Chisnall 6229729cf09SDimitry Andric#ifdef _LIBCPP_NO_EXCEPTIONS 6239729cf09SDimitry Andrictemplate <class _Iter> 6249729cf09SDimitry Andricstruct __libcpp_string_gets_noexcept_iterator_impl : public true_type {}; 6259729cf09SDimitry Andric#elif defined(_LIBCPP_HAS_NO_NOEXCEPT) 6269729cf09SDimitry Andrictemplate <class _Iter> 6279729cf09SDimitry Andricstruct __libcpp_string_gets_noexcept_iterator_impl : public false_type {}; 6289729cf09SDimitry Andric#else 6299729cf09SDimitry Andrictemplate <class _Iter, bool = __is_forward_iterator<_Iter>::value> 6309729cf09SDimitry Andricstruct __libcpp_string_gets_noexcept_iterator_impl : public _LIBCPP_BOOL_CONSTANT(( 6319729cf09SDimitry Andric noexcept(++(declval<_Iter&>())) && 6329729cf09SDimitry Andric is_nothrow_assignable<_Iter&, _Iter>::value && 6339729cf09SDimitry Andric noexcept(declval<_Iter>() == declval<_Iter>()) && 6349729cf09SDimitry Andric noexcept(*declval<_Iter>()) 6359729cf09SDimitry Andric)) {}; 6369729cf09SDimitry Andric 6379729cf09SDimitry Andrictemplate <class _Iter> 6389729cf09SDimitry Andricstruct __libcpp_string_gets_noexcept_iterator_impl<_Iter, false> : public false_type {}; 6399729cf09SDimitry Andric#endif 6409729cf09SDimitry Andric 6419729cf09SDimitry Andric 6429729cf09SDimitry Andrictemplate <class _Iter> 6439729cf09SDimitry Andricstruct __libcpp_string_gets_noexcept_iterator 6449729cf09SDimitry Andric : public _LIBCPP_BOOL_CONSTANT(__libcpp_is_trivial_iterator<_Iter>::value || __libcpp_string_gets_noexcept_iterator_impl<_Iter>::value) {}; 6459729cf09SDimitry Andric 646aed8d94eSDimitry Andrictemplate <class _CharT, class _Traits, class _Tp> 647aed8d94eSDimitry Andricstruct __can_be_converted_to_string_view : public _LIBCPP_BOOL_CONSTANT( 648aed8d94eSDimitry Andric ( is_convertible<const _Tp&, basic_string_view<_CharT, _Traits> >::value && 649aed8d94eSDimitry Andric !is_convertible<const _Tp&, const _CharT*>::value)) {}; 650aed8d94eSDimitry Andric 6519729cf09SDimitry Andric#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT 6524bab9fd9SDavid Chisnall 6534bab9fd9SDavid Chisnalltemplate <class _CharT, size_t = sizeof(_CharT)> 6544bab9fd9SDavid Chisnallstruct __padding 6554bab9fd9SDavid Chisnall{ 6564bab9fd9SDavid Chisnall unsigned char __xx[sizeof(_CharT)-1]; 6574bab9fd9SDavid Chisnall}; 6584bab9fd9SDavid Chisnall 6594bab9fd9SDavid Chisnalltemplate <class _CharT> 6604bab9fd9SDavid Chisnallstruct __padding<_CharT, 1> 6614bab9fd9SDavid Chisnall{ 6624bab9fd9SDavid Chisnall}; 6634bab9fd9SDavid Chisnall 6649729cf09SDimitry Andric#endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT 6654bab9fd9SDavid Chisnall 6667a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 667aed8d94eSDimitry Andricclass _LIBCPP_TEMPLATE_VIS basic_string 6687a984708SDavid Chisnall : private __basic_string_common<true> 6697a984708SDavid Chisnall{ 6707a984708SDavid Chisnallpublic: 6717a984708SDavid Chisnall typedef basic_string __self; 672aed8d94eSDimitry Andric typedef basic_string_view<_CharT, _Traits> __self_view; 6737a984708SDavid Chisnall typedef _Traits traits_type; 674540d2a8bSDimitry Andric typedef _CharT value_type; 6757a984708SDavid Chisnall typedef _Allocator allocator_type; 6767a984708SDavid Chisnall typedef allocator_traits<allocator_type> __alloc_traits; 6777a984708SDavid Chisnall typedef typename __alloc_traits::size_type size_type; 6787a984708SDavid Chisnall typedef typename __alloc_traits::difference_type difference_type; 6797a984708SDavid Chisnall typedef value_type& reference; 6807a984708SDavid Chisnall typedef const value_type& const_reference; 6817a984708SDavid Chisnall typedef typename __alloc_traits::pointer pointer; 6827a984708SDavid Chisnall typedef typename __alloc_traits::const_pointer const_pointer; 6837a984708SDavid Chisnall 6844ba319b5SDimitry Andric static_assert((!is_array<value_type>::value), "Character type of basic_string must not be an array"); 6854ba319b5SDimitry Andric static_assert(( is_standard_layout<value_type>::value), "Character type of basic_string must be standard-layout"); 6864ba319b5SDimitry Andric static_assert(( is_trivial<value_type>::value), "Character type of basic_string must be trivial"); 687540d2a8bSDimitry Andric static_assert(( is_same<_CharT, typename traits_type::char_type>::value), 6884f7ab58eSDimitry Andric "traits_type::char_type must be the same type as CharT"); 6894f7ab58eSDimitry Andric static_assert(( is_same<typename allocator_type::value_type, value_type>::value), 6904f7ab58eSDimitry Andric "Allocator::value_type must be same type as value_type"); 6914ba319b5SDimitry Andric 6924f7ab58eSDimitry Andric#if defined(_LIBCPP_RAW_ITERATORS) 6937a984708SDavid Chisnall typedef pointer iterator; 6947a984708SDavid Chisnall typedef const_pointer const_iterator; 6957a984708SDavid Chisnall#else // defined(_LIBCPP_RAW_ITERATORS) 6967a984708SDavid Chisnall typedef __wrap_iter<pointer> iterator; 6977a984708SDavid Chisnall typedef __wrap_iter<const_pointer> const_iterator; 6987a984708SDavid Chisnall#endif // defined(_LIBCPP_RAW_ITERATORS) 6997a984708SDavid Chisnall typedef _VSTD::reverse_iterator<iterator> reverse_iterator; 7007a984708SDavid Chisnall typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; 7017a984708SDavid Chisnall 7027a984708SDavid Chisnallprivate: 7034bab9fd9SDavid Chisnall 7049729cf09SDimitry Andric#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT 7054bab9fd9SDavid Chisnall 7064bab9fd9SDavid Chisnall struct __long 7074bab9fd9SDavid Chisnall { 7084bab9fd9SDavid Chisnall pointer __data_; 7094bab9fd9SDavid Chisnall size_type __size_; 7104bab9fd9SDavid Chisnall size_type __cap_; 7114bab9fd9SDavid Chisnall }; 7124bab9fd9SDavid Chisnall 713b2c7081bSDimitry Andric#ifdef _LIBCPP_BIG_ENDIAN 714c4394386SDimitry Andric static const size_type __short_mask = 0x01; 715c4394386SDimitry Andric static const size_type __long_mask = 0x1ul; 7164bab9fd9SDavid Chisnall#else // _LIBCPP_BIG_ENDIAN 717c4394386SDimitry Andric static const size_type __short_mask = 0x80; 718c4394386SDimitry Andric static const size_type __long_mask = ~(size_type(~0) >> 1); 7194bab9fd9SDavid Chisnall#endif // _LIBCPP_BIG_ENDIAN 7204bab9fd9SDavid Chisnall 7214bab9fd9SDavid Chisnall enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ? 7224bab9fd9SDavid Chisnall (sizeof(__long) - 1)/sizeof(value_type) : 2}; 7234bab9fd9SDavid Chisnall 7244bab9fd9SDavid Chisnall struct __short 7254bab9fd9SDavid Chisnall { 7264bab9fd9SDavid Chisnall value_type __data_[__min_cap]; 7274bab9fd9SDavid Chisnall struct 7284bab9fd9SDavid Chisnall : __padding<value_type> 7294bab9fd9SDavid Chisnall { 7304bab9fd9SDavid Chisnall unsigned char __size_; 7314bab9fd9SDavid Chisnall }; 7324bab9fd9SDavid Chisnall }; 7334bab9fd9SDavid Chisnall 7344bab9fd9SDavid Chisnall#else 7354bab9fd9SDavid Chisnall 7367a984708SDavid Chisnall struct __long 7377a984708SDavid Chisnall { 7387a984708SDavid Chisnall size_type __cap_; 7397a984708SDavid Chisnall size_type __size_; 7407a984708SDavid Chisnall pointer __data_; 7417a984708SDavid Chisnall }; 7427a984708SDavid Chisnall 743b2c7081bSDimitry Andric#ifdef _LIBCPP_BIG_ENDIAN 744c4394386SDimitry Andric static const size_type __short_mask = 0x80; 745c4394386SDimitry Andric static const size_type __long_mask = ~(size_type(~0) >> 1); 7467a984708SDavid Chisnall#else // _LIBCPP_BIG_ENDIAN 747c4394386SDimitry Andric static const size_type __short_mask = 0x01; 748c4394386SDimitry Andric static const size_type __long_mask = 0x1ul; 7497a984708SDavid Chisnall#endif // _LIBCPP_BIG_ENDIAN 7507a984708SDavid Chisnall 7517a984708SDavid Chisnall enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ? 7527a984708SDavid Chisnall (sizeof(__long) - 1)/sizeof(value_type) : 2}; 7537a984708SDavid Chisnall 7547a984708SDavid Chisnall struct __short 7557a984708SDavid Chisnall { 7567a984708SDavid Chisnall union 7577a984708SDavid Chisnall { 7587a984708SDavid Chisnall unsigned char __size_; 7591e0896acSDavid Chisnall value_type __lx; 7607a984708SDavid Chisnall }; 7617a984708SDavid Chisnall value_type __data_[__min_cap]; 7627a984708SDavid Chisnall }; 7637a984708SDavid Chisnall 7649729cf09SDimitry Andric#endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT 7654bab9fd9SDavid Chisnall 7664f7ab58eSDimitry Andric union __ulx{__long __lx; __short __lxx;}; 7677a984708SDavid Chisnall 7684f7ab58eSDimitry Andric enum {__n_words = sizeof(__ulx) / sizeof(size_type)}; 7697a984708SDavid Chisnall 7707a984708SDavid Chisnall struct __raw 7717a984708SDavid Chisnall { 7727a984708SDavid Chisnall size_type __words[__n_words]; 7737a984708SDavid Chisnall }; 7747a984708SDavid Chisnall 7757a984708SDavid Chisnall struct __rep 7767a984708SDavid Chisnall { 7777a984708SDavid Chisnall union 7787a984708SDavid Chisnall { 7797a984708SDavid Chisnall __long __l; 7807a984708SDavid Chisnall __short __s; 7817a984708SDavid Chisnall __raw __r; 7827a984708SDavid Chisnall }; 7837a984708SDavid Chisnall }; 7847a984708SDavid Chisnall 7857a984708SDavid Chisnall __compressed_pair<__rep, allocator_type> __r_; 7867a984708SDavid Chisnall 7877a984708SDavid Chisnallpublic: 7887a984708SDavid Chisnall static const size_type npos = -1; 7897a984708SDavid Chisnall 7907a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY basic_string() 7917a984708SDavid Chisnall _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value); 792854fa44bSDimitry Andric 793854fa44bSDimitry Andric _LIBCPP_INLINE_VISIBILITY explicit basic_string(const allocator_type& __a) 794854fa44bSDimitry Andric#if _LIBCPP_STD_VER <= 14 795854fa44bSDimitry Andric _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value); 796854fa44bSDimitry Andric#else 797854fa44bSDimitry Andric _NOEXCEPT; 798854fa44bSDimitry Andric#endif 799854fa44bSDimitry Andric 8007a984708SDavid Chisnall basic_string(const basic_string& __str); 8017a984708SDavid Chisnall basic_string(const basic_string& __str, const allocator_type& __a); 802854fa44bSDimitry Andric 803540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 8047a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 8057a984708SDavid Chisnall basic_string(basic_string&& __str) 806854fa44bSDimitry Andric#if _LIBCPP_STD_VER <= 14 8077a984708SDavid Chisnall _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value); 808854fa44bSDimitry Andric#else 809854fa44bSDimitry Andric _NOEXCEPT; 810854fa44bSDimitry Andric#endif 811854fa44bSDimitry Andric 8127a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 8137a984708SDavid Chisnall basic_string(basic_string&& __str, const allocator_type& __a); 814540d2a8bSDimitry Andric#endif // _LIBCPP_CXX03_LANG 8154ba319b5SDimitry Andric 816*b5893f02SDimitry Andric#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES 8174ba319b5SDimitry Andric template <class = typename enable_if<__is_allocator<_Allocator>::value, nullptr_t>::type> 818*b5893f02SDimitry Andric#endif 8194ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 8204ba319b5SDimitry Andric basic_string(const _CharT* __s) { 8214ba319b5SDimitry Andric _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*) detected nullptr"); 8224ba319b5SDimitry Andric __init(__s, traits_type::length(__s)); 8234ba319b5SDimitry Andric# if _LIBCPP_DEBUG_LEVEL >= 2 8244ba319b5SDimitry Andric __get_db()->__insert_c(this); 8254ba319b5SDimitry Andric# endif 8264ba319b5SDimitry Andric } 8274ba319b5SDimitry Andric 828*b5893f02SDimitry Andric#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES 8294ba319b5SDimitry Andric template <class = typename enable_if<__is_allocator<_Allocator>::value, nullptr_t>::type> 830*b5893f02SDimitry Andric#endif 8317a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 832540d2a8bSDimitry Andric basic_string(const _CharT* __s, const _Allocator& __a); 8334ba319b5SDimitry Andric 8347a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 835540d2a8bSDimitry Andric basic_string(const _CharT* __s, size_type __n); 8367a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 837540d2a8bSDimitry Andric basic_string(const _CharT* __s, size_type __n, const _Allocator& __a); 8387a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 839540d2a8bSDimitry Andric basic_string(size_type __n, _CharT __c); 8404ba319b5SDimitry Andric 841*b5893f02SDimitry Andric#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES 8424ba319b5SDimitry Andric template <class = typename enable_if<__is_allocator<_Allocator>::value, nullptr_t>::type> 843*b5893f02SDimitry Andric#endif 8447a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 845540d2a8bSDimitry Andric basic_string(size_type __n, _CharT __c, const _Allocator& __a); 8464ba319b5SDimitry Andric 8477c82a1ecSDimitry Andric basic_string(const basic_string& __str, size_type __pos, size_type __n, 848540d2a8bSDimitry Andric const _Allocator& __a = _Allocator()); 8497c82a1ecSDimitry Andric _LIBCPP_INLINE_VISIBILITY 8507c82a1ecSDimitry Andric basic_string(const basic_string& __str, size_type __pos, 851540d2a8bSDimitry Andric const _Allocator& __a = _Allocator()); 8524ba319b5SDimitry Andric 8534ba319b5SDimitry Andric template<class _Tp, class = typename enable_if<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, void>::type> 854540d2a8bSDimitry Andric _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 855aed8d94eSDimitry Andric basic_string(const _Tp& __t, size_type __pos, size_type __n, 8564ba319b5SDimitry Andric const allocator_type& __a = allocator_type()); 8574ba319b5SDimitry Andric 8584ba319b5SDimitry Andric template<class _Tp, class = typename enable_if<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, void>::type> 8594ba319b5SDimitry Andric _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 8604ba319b5SDimitry Andric explicit basic_string(const _Tp& __t); 8614ba319b5SDimitry Andric 8624ba319b5SDimitry Andric template<class _Tp, class = typename enable_if<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, void>::type> 8634ba319b5SDimitry Andric _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 8644ba319b5SDimitry Andric explicit basic_string(const _Tp& __t, const allocator_type& __a); 8654ba319b5SDimitry Andric 8667a984708SDavid Chisnall template<class _InputIterator> 8677a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 8687a984708SDavid Chisnall basic_string(_InputIterator __first, _InputIterator __last); 8697a984708SDavid Chisnall template<class _InputIterator> 8707a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 8717a984708SDavid Chisnall basic_string(_InputIterator __first, _InputIterator __last, const allocator_type& __a); 872540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 8737a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 874540d2a8bSDimitry Andric basic_string(initializer_list<_CharT> __il); 8757a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 876540d2a8bSDimitry Andric basic_string(initializer_list<_CharT> __il, const _Allocator& __a); 877540d2a8bSDimitry Andric#endif // _LIBCPP_CXX03_LANG 8787a984708SDavid Chisnall 879aed8d94eSDimitry Andric inline ~basic_string(); 880aed8d94eSDimitry Andric 881aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 882aed8d94eSDimitry Andric operator __self_view() const _NOEXCEPT { return __self_view(data(), size()); } 8837a984708SDavid Chisnall 8847a984708SDavid Chisnall basic_string& operator=(const basic_string& __str); 885f23c525cSDimitry Andric 8864ba319b5SDimitry Andric template <class _Tp, class = typename enable_if<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, void>::type> 8874ba319b5SDimitry Andric basic_string& operator=(const _Tp& __t) 8884ba319b5SDimitry Andric {__self_view __sv = __t; return assign(__sv);} 8894ba319b5SDimitry Andric 890540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 8917a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 8927a984708SDavid Chisnall basic_string& operator=(basic_string&& __str) 8939729cf09SDimitry Andric _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)); 894540d2a8bSDimitry Andric _LIBCPP_INLINE_VISIBILITY 895540d2a8bSDimitry Andric basic_string& operator=(initializer_list<value_type> __il) {return assign(__il.begin(), __il.size());} 8967a984708SDavid Chisnall#endif 8974bab9fd9SDavid Chisnall _LIBCPP_INLINE_VISIBILITY basic_string& operator=(const value_type* __s) {return assign(__s);} 8987a984708SDavid Chisnall basic_string& operator=(value_type __c); 8997a984708SDavid Chisnall 9004f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 9014f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 9024f7ab58eSDimitry Andric iterator begin() _NOEXCEPT 9034f7ab58eSDimitry Andric {return iterator(this, __get_pointer());} 9044f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 9054f7ab58eSDimitry Andric const_iterator begin() const _NOEXCEPT 9064f7ab58eSDimitry Andric {return const_iterator(this, __get_pointer());} 9074f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 9084f7ab58eSDimitry Andric iterator end() _NOEXCEPT 9094f7ab58eSDimitry Andric {return iterator(this, __get_pointer() + size());} 9104f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 9114f7ab58eSDimitry Andric const_iterator end() const _NOEXCEPT 9124f7ab58eSDimitry Andric {return const_iterator(this, __get_pointer() + size());} 9134f7ab58eSDimitry Andric#else 9147a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 9157a984708SDavid Chisnall iterator begin() _NOEXCEPT 9167a984708SDavid Chisnall {return iterator(__get_pointer());} 9177a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 9187a984708SDavid Chisnall const_iterator begin() const _NOEXCEPT 9194bab9fd9SDavid Chisnall {return const_iterator(__get_pointer());} 9207a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 9217a984708SDavid Chisnall iterator end() _NOEXCEPT 9227a984708SDavid Chisnall {return iterator(__get_pointer() + size());} 9237a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 9247a984708SDavid Chisnall const_iterator end() const _NOEXCEPT 9254bab9fd9SDavid Chisnall {return const_iterator(__get_pointer() + size());} 9264f7ab58eSDimitry Andric#endif // _LIBCPP_DEBUG_LEVEL >= 2 9277a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 9287a984708SDavid Chisnall reverse_iterator rbegin() _NOEXCEPT 9297a984708SDavid Chisnall {return reverse_iterator(end());} 9307a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 9317a984708SDavid Chisnall const_reverse_iterator rbegin() const _NOEXCEPT 9327a984708SDavid Chisnall {return const_reverse_iterator(end());} 9337a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 9347a984708SDavid Chisnall reverse_iterator rend() _NOEXCEPT 9357a984708SDavid Chisnall {return reverse_iterator(begin());} 9367a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 9377a984708SDavid Chisnall const_reverse_iterator rend() const _NOEXCEPT 9387a984708SDavid Chisnall {return const_reverse_iterator(begin());} 9397a984708SDavid Chisnall 9407a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 9417a984708SDavid Chisnall const_iterator cbegin() const _NOEXCEPT 9427a984708SDavid Chisnall {return begin();} 9437a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 9447a984708SDavid Chisnall const_iterator cend() const _NOEXCEPT 9457a984708SDavid Chisnall {return end();} 9467a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 9477a984708SDavid Chisnall const_reverse_iterator crbegin() const _NOEXCEPT 9487a984708SDavid Chisnall {return rbegin();} 9497a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 9507a984708SDavid Chisnall const_reverse_iterator crend() const _NOEXCEPT 9517a984708SDavid Chisnall {return rend();} 9527a984708SDavid Chisnall 9537a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY size_type size() const _NOEXCEPT 9547a984708SDavid Chisnall {return __is_long() ? __get_long_size() : __get_short_size();} 9557a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY size_type length() const _NOEXCEPT {return size();} 9567a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT; 9577a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY size_type capacity() const _NOEXCEPT 958163c8ab6SDimitry Andric {return (__is_long() ? __get_long_cap() 959163c8ab6SDimitry Andric : static_cast<size_type>(__min_cap)) - 1;} 9607a984708SDavid Chisnall 9617a984708SDavid Chisnall void resize(size_type __n, value_type __c); 9627a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY void resize(size_type __n) {resize(__n, value_type());} 9637a984708SDavid Chisnall 964*b5893f02SDimitry Andric void reserve(size_type __res_arg); 965*b5893f02SDimitry Andric _LIBCPP_INLINE_VISIBILITY void __resize_default_init(size_type __n); 966*b5893f02SDimitry Andric 967*b5893f02SDimitry Andric _LIBCPP_INLINE_VISIBILITY 968*b5893f02SDimitry Andric void reserve() _NOEXCEPT {reserve(0);} 9697a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 9707a984708SDavid Chisnall void shrink_to_fit() _NOEXCEPT {reserve();} 9717a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 9727a984708SDavid Chisnall void clear() _NOEXCEPT; 973b2c7081bSDimitry Andric _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY 974b2c7081bSDimitry Andric bool empty() const _NOEXCEPT {return size() == 0;} 9757a984708SDavid Chisnall 976aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __pos) const _NOEXCEPT; 977aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __pos) _NOEXCEPT; 9787a984708SDavid Chisnall 9797a984708SDavid Chisnall const_reference at(size_type __n) const; 9807a984708SDavid Chisnall reference at(size_type __n); 9817a984708SDavid Chisnall 9827a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(const basic_string& __str) {return append(__str);} 9834ba319b5SDimitry Andric 9844ba319b5SDimitry Andric template <class _Tp> 9854ba319b5SDimitry Andric _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 9864ba319b5SDimitry Andric typename enable_if 9874ba319b5SDimitry Andric < 9884ba319b5SDimitry Andric __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, 9894ba319b5SDimitry Andric basic_string& 9904ba319b5SDimitry Andric >::type 9914ba319b5SDimitry Andric operator+=(const _Tp& __t) {__self_view __sv = __t; return append(__sv);} 9924bab9fd9SDavid Chisnall _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(const value_type* __s) {return append(__s);} 9937a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(value_type __c) {push_back(__c); return *this;} 994540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 9957a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(initializer_list<value_type> __il) {return append(__il);} 996540d2a8bSDimitry Andric#endif // _LIBCPP_CXX03_LANG 9977a984708SDavid Chisnall 9987a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 9997a984708SDavid Chisnall basic_string& append(const basic_string& __str); 10004ba319b5SDimitry Andric 10014ba319b5SDimitry Andric template <class _Tp> 10024ba319b5SDimitry Andric _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 10034ba319b5SDimitry Andric typename enable_if 10044ba319b5SDimitry Andric < 10054ba319b5SDimitry Andric __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, 10064ba319b5SDimitry Andric basic_string& 10074ba319b5SDimitry Andric >::type 10084ba319b5SDimitry Andric append(const _Tp& __t) { __self_view __sv = __t; return append(__sv.data(), __sv.size()); } 1009d72607e9SDimitry Andric basic_string& append(const basic_string& __str, size_type __pos, size_type __n=npos); 10104ba319b5SDimitry Andric 1011aed8d94eSDimitry Andric template <class _Tp> 1012540d2a8bSDimitry Andric _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 1013aed8d94eSDimitry Andric typename enable_if 1014aed8d94eSDimitry Andric < 1015aed8d94eSDimitry Andric __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, 1016aed8d94eSDimitry Andric basic_string& 1017aed8d94eSDimitry Andric >::type 1018aed8d94eSDimitry Andric append(const _Tp& __t, size_type __pos, size_type __n=npos); 10194bab9fd9SDavid Chisnall basic_string& append(const value_type* __s, size_type __n); 10204bab9fd9SDavid Chisnall basic_string& append(const value_type* __s); 10217a984708SDavid Chisnall basic_string& append(size_type __n, value_type __c); 1022*b5893f02SDimitry Andric 1023*b5893f02SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1024*b5893f02SDimitry Andric void __append_default_init(size_type __n); 1025*b5893f02SDimitry Andric 1026aed8d94eSDimitry Andric template <class _ForwardIterator> 1027540d2a8bSDimitry Andric _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 1028540d2a8bSDimitry Andric basic_string& __append_forward_unsafe(_ForwardIterator, _ForwardIterator); 10297a984708SDavid Chisnall template<class _InputIterator> 1030540d2a8bSDimitry Andric _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 10317a984708SDavid Chisnall typename enable_if 10327a984708SDavid Chisnall < 10339729cf09SDimitry Andric __is_exactly_input_iterator<_InputIterator>::value 10349729cf09SDimitry Andric || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value, 10357a984708SDavid Chisnall basic_string& 10367a984708SDavid Chisnall >::type 1037aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 1038aed8d94eSDimitry Andric append(_InputIterator __first, _InputIterator __last) { 1039aed8d94eSDimitry Andric const basic_string __temp (__first, __last, __alloc()); 1040aed8d94eSDimitry Andric append(__temp.data(), __temp.size()); 1041aed8d94eSDimitry Andric return *this; 1042aed8d94eSDimitry Andric } 10437a984708SDavid Chisnall template<class _ForwardIterator> 1044540d2a8bSDimitry Andric _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 10457a984708SDavid Chisnall typename enable_if 10467a984708SDavid Chisnall < 10479729cf09SDimitry Andric __is_forward_iterator<_ForwardIterator>::value 10489729cf09SDimitry Andric && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value, 10497a984708SDavid Chisnall basic_string& 10507a984708SDavid Chisnall >::type 1051aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 1052aed8d94eSDimitry Andric append(_ForwardIterator __first, _ForwardIterator __last) { 1053aed8d94eSDimitry Andric return __append_forward_unsafe(__first, __last); 1054aed8d94eSDimitry Andric } 1055aed8d94eSDimitry Andric 1056540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 10577a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 10587a984708SDavid Chisnall basic_string& append(initializer_list<value_type> __il) {return append(__il.begin(), __il.size());} 1059540d2a8bSDimitry Andric#endif // _LIBCPP_CXX03_LANG 10607a984708SDavid Chisnall 10617a984708SDavid Chisnall void push_back(value_type __c); 10627a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 10637a984708SDavid Chisnall void pop_back(); 10647a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY reference front(); 10657a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY const_reference front() const; 10667a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY reference back(); 10677a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY const_reference back() const; 10687a984708SDavid Chisnall 10694ba319b5SDimitry Andric template <class _Tp> 10704ba319b5SDimitry Andric _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 10714ba319b5SDimitry Andric typename enable_if 10724ba319b5SDimitry Andric < 10734ba319b5SDimitry Andric __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, 10744ba319b5SDimitry Andric basic_string& 10754ba319b5SDimitry Andric >::type 10764ba319b5SDimitry Andric assign(const _Tp & __t) { __self_view __sv = __t; return assign(__sv.data(), __sv.size()); } 1077aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 10787c82a1ecSDimitry Andric basic_string& assign(const basic_string& __str) { return *this = __str; } 1079540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 10807a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 1081f9448bf3SDimitry Andric basic_string& assign(basic_string&& __str) 10829729cf09SDimitry Andric _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) 1083f9448bf3SDimitry Andric {*this = _VSTD::move(__str); return *this;} 10847a984708SDavid Chisnall#endif 1085d72607e9SDimitry Andric basic_string& assign(const basic_string& __str, size_type __pos, size_type __n=npos); 1086aed8d94eSDimitry Andric template <class _Tp> 1087540d2a8bSDimitry Andric _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 1088aed8d94eSDimitry Andric typename enable_if 1089aed8d94eSDimitry Andric < 1090aed8d94eSDimitry Andric __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, 1091aed8d94eSDimitry Andric basic_string& 1092aed8d94eSDimitry Andric >::type 1093f9448bf3SDimitry Andric assign(const _Tp & __t, size_type __pos, size_type __n=npos); 10944bab9fd9SDavid Chisnall basic_string& assign(const value_type* __s, size_type __n); 10954bab9fd9SDavid Chisnall basic_string& assign(const value_type* __s); 10967a984708SDavid Chisnall basic_string& assign(size_type __n, value_type __c); 10977a984708SDavid Chisnall template<class _InputIterator> 1098540d2a8bSDimitry Andric _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 10997a984708SDavid Chisnall typename enable_if 11007a984708SDavid Chisnall < 11019729cf09SDimitry Andric __is_exactly_input_iterator<_InputIterator>::value 11029729cf09SDimitry Andric || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value, 11037a984708SDavid Chisnall basic_string& 11047a984708SDavid Chisnall >::type 11057a984708SDavid Chisnall assign(_InputIterator __first, _InputIterator __last); 11067a984708SDavid Chisnall template<class _ForwardIterator> 1107540d2a8bSDimitry Andric _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 11087a984708SDavid Chisnall typename enable_if 11097a984708SDavid Chisnall < 11109729cf09SDimitry Andric __is_forward_iterator<_ForwardIterator>::value 11119729cf09SDimitry Andric && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value, 11127a984708SDavid Chisnall basic_string& 11137a984708SDavid Chisnall >::type 11147a984708SDavid Chisnall assign(_ForwardIterator __first, _ForwardIterator __last); 1115540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 11167a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 11177a984708SDavid Chisnall basic_string& assign(initializer_list<value_type> __il) {return assign(__il.begin(), __il.size());} 1118540d2a8bSDimitry Andric#endif // _LIBCPP_CXX03_LANG 11197a984708SDavid Chisnall 11207a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 11217a984708SDavid Chisnall basic_string& insert(size_type __pos1, const basic_string& __str); 11224ba319b5SDimitry Andric 11234ba319b5SDimitry Andric template <class _Tp> 11244ba319b5SDimitry Andric _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 11254ba319b5SDimitry Andric typename enable_if 11264ba319b5SDimitry Andric < 11274ba319b5SDimitry Andric __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, 11284ba319b5SDimitry Andric basic_string& 11294ba319b5SDimitry Andric >::type 11304ba319b5SDimitry Andric insert(size_type __pos1, const _Tp& __t) 11314ba319b5SDimitry Andric { __self_view __sv = __t; return insert(__pos1, __sv.data(), __sv.size()); } 11324ba319b5SDimitry Andric 1133aed8d94eSDimitry Andric template <class _Tp> 1134540d2a8bSDimitry Andric _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 1135aed8d94eSDimitry Andric typename enable_if 1136aed8d94eSDimitry Andric < 1137aed8d94eSDimitry Andric __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, 1138aed8d94eSDimitry Andric basic_string& 1139aed8d94eSDimitry Andric >::type 1140aed8d94eSDimitry Andric insert(size_type __pos1, const _Tp& __t, size_type __pos2, size_type __n=npos); 1141d72607e9SDimitry Andric basic_string& insert(size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n=npos); 11424bab9fd9SDavid Chisnall basic_string& insert(size_type __pos, const value_type* __s, size_type __n); 11434bab9fd9SDavid Chisnall basic_string& insert(size_type __pos, const value_type* __s); 11447a984708SDavid Chisnall basic_string& insert(size_type __pos, size_type __n, value_type __c); 11457a984708SDavid Chisnall iterator insert(const_iterator __pos, value_type __c); 11467a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 11477a984708SDavid Chisnall iterator insert(const_iterator __pos, size_type __n, value_type __c); 11487a984708SDavid Chisnall template<class _InputIterator> 1149540d2a8bSDimitry Andric _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 11507a984708SDavid Chisnall typename enable_if 11517a984708SDavid Chisnall < 11529729cf09SDimitry Andric __is_exactly_input_iterator<_InputIterator>::value 11539729cf09SDimitry Andric || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value, 11547a984708SDavid Chisnall iterator 11557a984708SDavid Chisnall >::type 11567a984708SDavid Chisnall insert(const_iterator __pos, _InputIterator __first, _InputIterator __last); 11577a984708SDavid Chisnall template<class _ForwardIterator> 1158540d2a8bSDimitry Andric _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 11597a984708SDavid Chisnall typename enable_if 11607a984708SDavid Chisnall < 11619729cf09SDimitry Andric __is_forward_iterator<_ForwardIterator>::value 11629729cf09SDimitry Andric && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value, 11637a984708SDavid Chisnall iterator 11647a984708SDavid Chisnall >::type 11657a984708SDavid Chisnall insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last); 1166540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 11677a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 11687a984708SDavid Chisnall iterator insert(const_iterator __pos, initializer_list<value_type> __il) 11697a984708SDavid Chisnall {return insert(__pos, __il.begin(), __il.end());} 1170540d2a8bSDimitry Andric#endif // _LIBCPP_CXX03_LANG 11717a984708SDavid Chisnall 11727a984708SDavid Chisnall basic_string& erase(size_type __pos = 0, size_type __n = npos); 11737a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 11747a984708SDavid Chisnall iterator erase(const_iterator __pos); 11757a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 11767a984708SDavid Chisnall iterator erase(const_iterator __first, const_iterator __last); 11777a984708SDavid Chisnall 11787a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 11797a984708SDavid Chisnall basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str); 11804ba319b5SDimitry Andric 11814ba319b5SDimitry Andric template <class _Tp> 11824ba319b5SDimitry Andric _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 11834ba319b5SDimitry Andric typename enable_if 11844ba319b5SDimitry Andric < 11854ba319b5SDimitry Andric __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, 11864ba319b5SDimitry Andric basic_string& 11874ba319b5SDimitry Andric >::type 11884ba319b5SDimitry Andric replace(size_type __pos1, size_type __n1, const _Tp& __t) { __self_view __sv = __t; return replace(__pos1, __n1, __sv.data(), __sv.size()); } 1189d72607e9SDimitry Andric basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2=npos); 1190aed8d94eSDimitry Andric template <class _Tp> 1191540d2a8bSDimitry Andric _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 1192aed8d94eSDimitry Andric typename enable_if 1193aed8d94eSDimitry Andric < 1194aed8d94eSDimitry Andric __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, 1195aed8d94eSDimitry Andric basic_string& 1196aed8d94eSDimitry Andric >::type 1197aed8d94eSDimitry Andric replace(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2=npos); 11984bab9fd9SDavid Chisnall basic_string& replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2); 11994bab9fd9SDavid Chisnall basic_string& replace(size_type __pos, size_type __n1, const value_type* __s); 12007a984708SDavid Chisnall basic_string& replace(size_type __pos, size_type __n1, size_type __n2, value_type __c); 12017a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 12027a984708SDavid Chisnall basic_string& replace(const_iterator __i1, const_iterator __i2, const basic_string& __str); 12034ba319b5SDimitry Andric 12044ba319b5SDimitry Andric template <class _Tp> 12054ba319b5SDimitry Andric _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 12064ba319b5SDimitry Andric typename enable_if 12074ba319b5SDimitry Andric < 12084ba319b5SDimitry Andric __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, 12094ba319b5SDimitry Andric basic_string& 12104ba319b5SDimitry Andric >::type 12114ba319b5SDimitry Andric replace(const_iterator __i1, const_iterator __i2, const _Tp& __t) { __self_view __sv = __t; return replace(__i1 - begin(), __i2 - __i1, __sv); } 12124ba319b5SDimitry Andric 1213aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 12144bab9fd9SDavid Chisnall basic_string& replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n); 12157a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 12164bab9fd9SDavid Chisnall basic_string& replace(const_iterator __i1, const_iterator __i2, const value_type* __s); 12177a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 12187a984708SDavid Chisnall basic_string& replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c); 12197a984708SDavid Chisnall template<class _InputIterator> 1220540d2a8bSDimitry Andric _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 12217a984708SDavid Chisnall typename enable_if 12227a984708SDavid Chisnall < 12237a984708SDavid Chisnall __is_input_iterator<_InputIterator>::value, 12247a984708SDavid Chisnall basic_string& 12257a984708SDavid Chisnall >::type 12267a984708SDavid Chisnall replace(const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2); 1227540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 12287a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 12297a984708SDavid Chisnall basic_string& replace(const_iterator __i1, const_iterator __i2, initializer_list<value_type> __il) 12307a984708SDavid Chisnall {return replace(__i1, __i2, __il.begin(), __il.end());} 1231540d2a8bSDimitry Andric#endif // _LIBCPP_CXX03_LANG 12327a984708SDavid Chisnall 12334bab9fd9SDavid Chisnall size_type copy(value_type* __s, size_type __n, size_type __pos = 0) const; 12347a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 12357a984708SDavid Chisnall basic_string substr(size_type __pos = 0, size_type __n = npos) const; 12367a984708SDavid Chisnall 12377a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 12387a984708SDavid Chisnall void swap(basic_string& __str) 1239854fa44bSDimitry Andric#if _LIBCPP_STD_VER >= 14 1240aed8d94eSDimitry Andric _NOEXCEPT_DEBUG; 1241854fa44bSDimitry Andric#else 1242aed8d94eSDimitry Andric _NOEXCEPT_DEBUG_(!__alloc_traits::propagate_on_container_swap::value || 12437a984708SDavid Chisnall __is_nothrow_swappable<allocator_type>::value); 1244854fa44bSDimitry Andric#endif 12457a984708SDavid Chisnall 12467a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 12474bab9fd9SDavid Chisnall const value_type* c_str() const _NOEXCEPT {return data();} 12487a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 12494bab9fd9SDavid Chisnall const value_type* data() const _NOEXCEPT {return _VSTD::__to_raw_pointer(__get_pointer());} 1250b2c7081bSDimitry Andric#if _LIBCPP_STD_VER > 14 || defined(_LIBCPP_BUILDING_LIBRARY) 12517c82a1ecSDimitry Andric _LIBCPP_INLINE_VISIBILITY 12527c82a1ecSDimitry Andric value_type* data() _NOEXCEPT {return _VSTD::__to_raw_pointer(__get_pointer());} 12537c82a1ecSDimitry Andric#endif 12547a984708SDavid Chisnall 12557a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 12567a984708SDavid Chisnall allocator_type get_allocator() const _NOEXCEPT {return __alloc();} 12577a984708SDavid Chisnall 12587a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 12597a984708SDavid Chisnall size_type find(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT; 12604ba319b5SDimitry Andric 12614ba319b5SDimitry Andric template <class _Tp> 12624ba319b5SDimitry Andric _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 12634ba319b5SDimitry Andric typename enable_if 12644ba319b5SDimitry Andric < 12654ba319b5SDimitry Andric __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, 12664ba319b5SDimitry Andric size_type 12674ba319b5SDimitry Andric >::type 12684ba319b5SDimitry Andric find(const _Tp& __t, size_type __pos = 0) const; 12694bab9fd9SDavid Chisnall size_type find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; 12707a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 12714bab9fd9SDavid Chisnall size_type find(const value_type* __s, size_type __pos = 0) const _NOEXCEPT; 12727a984708SDavid Chisnall size_type find(value_type __c, size_type __pos = 0) const _NOEXCEPT; 12737a984708SDavid Chisnall 12747a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 12757a984708SDavid Chisnall size_type rfind(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT; 12764ba319b5SDimitry Andric 12774ba319b5SDimitry Andric template <class _Tp> 12784ba319b5SDimitry Andric _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 12794ba319b5SDimitry Andric typename enable_if 12804ba319b5SDimitry Andric < 12814ba319b5SDimitry Andric __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, 12824ba319b5SDimitry Andric size_type 12834ba319b5SDimitry Andric >::type 12844ba319b5SDimitry Andric rfind(const _Tp& __t, size_type __pos = npos) const; 12854bab9fd9SDavid Chisnall size_type rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; 12867a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 12874bab9fd9SDavid Chisnall size_type rfind(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; 12887a984708SDavid Chisnall size_type rfind(value_type __c, size_type __pos = npos) const _NOEXCEPT; 12897a984708SDavid Chisnall 12907a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 12917a984708SDavid Chisnall size_type find_first_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT; 12924ba319b5SDimitry Andric 12934ba319b5SDimitry Andric template <class _Tp> 12944ba319b5SDimitry Andric _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 12954ba319b5SDimitry Andric typename enable_if 12964ba319b5SDimitry Andric < 12974ba319b5SDimitry Andric __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, 12984ba319b5SDimitry Andric size_type 12994ba319b5SDimitry Andric >::type 13004ba319b5SDimitry Andric find_first_of(const _Tp& __t, size_type __pos = 0) const; 13014bab9fd9SDavid Chisnall size_type find_first_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; 13027a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 13034bab9fd9SDavid Chisnall size_type find_first_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT; 13047a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 13057a984708SDavid Chisnall size_type find_first_of(value_type __c, size_type __pos = 0) const _NOEXCEPT; 13067a984708SDavid Chisnall 13077a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 13087a984708SDavid Chisnall size_type find_last_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT; 13094ba319b5SDimitry Andric 13104ba319b5SDimitry Andric template <class _Tp> 13114ba319b5SDimitry Andric _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 13124ba319b5SDimitry Andric typename enable_if 13134ba319b5SDimitry Andric < 13144ba319b5SDimitry Andric __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, 13154ba319b5SDimitry Andric size_type 13164ba319b5SDimitry Andric >::type 13174ba319b5SDimitry Andric find_last_of(const _Tp& __t, size_type __pos = npos) const; 13184bab9fd9SDavid Chisnall size_type find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; 13197a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 13204bab9fd9SDavid Chisnall size_type find_last_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; 13217a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 13227a984708SDavid Chisnall size_type find_last_of(value_type __c, size_type __pos = npos) const _NOEXCEPT; 13237a984708SDavid Chisnall 13247a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 13257a984708SDavid Chisnall size_type find_first_not_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT; 13264ba319b5SDimitry Andric 13274ba319b5SDimitry Andric template <class _Tp> 13284ba319b5SDimitry Andric _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 13294ba319b5SDimitry Andric typename enable_if 13304ba319b5SDimitry Andric < 13314ba319b5SDimitry Andric __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, 13324ba319b5SDimitry Andric size_type 13334ba319b5SDimitry Andric >::type 13344ba319b5SDimitry Andric find_first_not_of(const _Tp &__t, size_type __pos = 0) const; 13354bab9fd9SDavid Chisnall size_type find_first_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; 13367a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 13374bab9fd9SDavid Chisnall size_type find_first_not_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT; 13387a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 13397a984708SDavid Chisnall size_type find_first_not_of(value_type __c, size_type __pos = 0) const _NOEXCEPT; 13407a984708SDavid Chisnall 13417a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 13427a984708SDavid Chisnall size_type find_last_not_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT; 13434ba319b5SDimitry Andric 13444ba319b5SDimitry Andric template <class _Tp> 13454ba319b5SDimitry Andric _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 13464ba319b5SDimitry Andric typename enable_if 13474ba319b5SDimitry Andric < 13484ba319b5SDimitry Andric __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, 13494ba319b5SDimitry Andric size_type 13504ba319b5SDimitry Andric >::type 13514ba319b5SDimitry Andric find_last_not_of(const _Tp& __t, size_type __pos = npos) const; 13524bab9fd9SDavid Chisnall size_type find_last_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; 13537a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 13544bab9fd9SDavid Chisnall size_type find_last_not_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; 13557a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 13567a984708SDavid Chisnall size_type find_last_not_of(value_type __c, size_type __pos = npos) const _NOEXCEPT; 13577a984708SDavid Chisnall 13587a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 13597a984708SDavid Chisnall int compare(const basic_string& __str) const _NOEXCEPT; 13604ba319b5SDimitry Andric 13614ba319b5SDimitry Andric template <class _Tp> 13624ba319b5SDimitry Andric _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 13634ba319b5SDimitry Andric typename enable_if 13644ba319b5SDimitry Andric < 13654ba319b5SDimitry Andric __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, 13664ba319b5SDimitry Andric int 13674ba319b5SDimitry Andric >::type 13684ba319b5SDimitry Andric compare(const _Tp &__t) const; 13694ba319b5SDimitry Andric 13704ba319b5SDimitry Andric template <class _Tp> 13714ba319b5SDimitry Andric _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS 13724ba319b5SDimitry Andric typename enable_if 13734ba319b5SDimitry Andric < 13744ba319b5SDimitry Andric __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, 13754ba319b5SDimitry Andric int 13764ba319b5SDimitry Andric >::type 13774ba319b5SDimitry Andric compare(size_type __pos1, size_type __n1, const _Tp& __t) const; 13784ba319b5SDimitry Andric 1379aed8d94eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 13807a984708SDavid Chisnall int compare(size_type __pos1, size_type __n1, const basic_string& __str) const; 1381d72607e9SDimitry Andric int compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2=npos) const; 13824ba319b5SDimitry Andric 1383aed8d94eSDimitry Andric template <class _Tp> 1384aed8d94eSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 1385aed8d94eSDimitry Andric typename enable_if 1386aed8d94eSDimitry Andric < 1387aed8d94eSDimitry Andric __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, 1388aed8d94eSDimitry Andric int 1389aed8d94eSDimitry Andric >::type 1390aed8d94eSDimitry Andric compare(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2=npos) const; 13914bab9fd9SDavid Chisnall int compare(const value_type* __s) const _NOEXCEPT; 13924bab9fd9SDavid Chisnall int compare(size_type __pos1, size_type __n1, const value_type* __s) const; 13934bab9fd9SDavid Chisnall int compare(size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const; 13947a984708SDavid Chisnall 1395b2c7081bSDimitry Andric#if _LIBCPP_STD_VER > 17 1396b2c7081bSDimitry Andric _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 1397b2c7081bSDimitry Andric bool starts_with(__self_view __sv) const _NOEXCEPT 1398b2c7081bSDimitry Andric { return __self_view(data(), size()).starts_with(__sv); } 1399b2c7081bSDimitry Andric 1400b2c7081bSDimitry Andric _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 1401b2c7081bSDimitry Andric bool starts_with(value_type __c) const _NOEXCEPT 1402b2c7081bSDimitry Andric { return !empty() && _Traits::eq(front(), __c); } 1403b2c7081bSDimitry Andric 1404b2c7081bSDimitry Andric _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 1405b2c7081bSDimitry Andric bool starts_with(const value_type* __s) const _NOEXCEPT 1406b2c7081bSDimitry Andric { return starts_with(__self_view(__s)); } 1407b2c7081bSDimitry Andric 1408b2c7081bSDimitry Andric _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 1409b2c7081bSDimitry Andric bool ends_with(__self_view __sv) const _NOEXCEPT 1410b2c7081bSDimitry Andric { return __self_view(data(), size()).ends_with( __sv); } 1411b2c7081bSDimitry Andric 1412b2c7081bSDimitry Andric _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 1413b2c7081bSDimitry Andric bool ends_with(value_type __c) const _NOEXCEPT 1414b2c7081bSDimitry Andric { return !empty() && _Traits::eq(back(), __c); } 1415b2c7081bSDimitry Andric 1416b2c7081bSDimitry Andric _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 1417b2c7081bSDimitry Andric bool ends_with(const value_type* __s) const _NOEXCEPT 1418b2c7081bSDimitry Andric { return ends_with(__self_view(__s)); } 1419b2c7081bSDimitry Andric#endif 1420b2c7081bSDimitry Andric 14217a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY bool __invariants() const; 14221bf9f7c1SDimitry Andric 14234ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY void __clear_and_shrink() _NOEXCEPT; 14244ba319b5SDimitry Andric 14251bf9f7c1SDimitry Andric _LIBCPP_INLINE_VISIBILITY 14261bf9f7c1SDimitry Andric bool __is_long() const _NOEXCEPT 14271bf9f7c1SDimitry Andric {return bool(__r_.first().__s.__size_ & __short_mask);} 14281bf9f7c1SDimitry Andric 14294f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 14304f7ab58eSDimitry Andric 14314f7ab58eSDimitry Andric bool __dereferenceable(const const_iterator* __i) const; 14324f7ab58eSDimitry Andric bool __decrementable(const const_iterator* __i) const; 14334f7ab58eSDimitry Andric bool __addable(const const_iterator* __i, ptrdiff_t __n) const; 14344f7ab58eSDimitry Andric bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const; 14354f7ab58eSDimitry Andric 14364f7ab58eSDimitry Andric#endif // _LIBCPP_DEBUG_LEVEL >= 2 14374f7ab58eSDimitry Andric 14387a984708SDavid Chisnallprivate: 14397a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 14407a984708SDavid Chisnall allocator_type& __alloc() _NOEXCEPT 14417a984708SDavid Chisnall {return __r_.second();} 14427a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 14437a984708SDavid Chisnall const allocator_type& __alloc() const _NOEXCEPT 14447a984708SDavid Chisnall {return __r_.second();} 14457a984708SDavid Chisnall 14469729cf09SDimitry Andric#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT 14474bab9fd9SDavid Chisnall 14484bab9fd9SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 14494bab9fd9SDavid Chisnall void __set_short_size(size_type __s) _NOEXCEPT 1450b2c7081bSDimitry Andric# ifdef _LIBCPP_BIG_ENDIAN 14514bab9fd9SDavid Chisnall {__r_.first().__s.__size_ = (unsigned char)(__s << 1);} 14524bab9fd9SDavid Chisnall# else 14534bab9fd9SDavid Chisnall {__r_.first().__s.__size_ = (unsigned char)(__s);} 14544bab9fd9SDavid Chisnall# endif 14554bab9fd9SDavid Chisnall 14564bab9fd9SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 14574bab9fd9SDavid Chisnall size_type __get_short_size() const _NOEXCEPT 1458b2c7081bSDimitry Andric# ifdef _LIBCPP_BIG_ENDIAN 14594bab9fd9SDavid Chisnall {return __r_.first().__s.__size_ >> 1;} 14604bab9fd9SDavid Chisnall# else 14614bab9fd9SDavid Chisnall {return __r_.first().__s.__size_;} 14624bab9fd9SDavid Chisnall# endif 14634bab9fd9SDavid Chisnall 14649729cf09SDimitry Andric#else // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT 14654bab9fd9SDavid Chisnall 14667a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 14677a984708SDavid Chisnall void __set_short_size(size_type __s) _NOEXCEPT 1468b2c7081bSDimitry Andric# ifdef _LIBCPP_BIG_ENDIAN 14697a984708SDavid Chisnall {__r_.first().__s.__size_ = (unsigned char)(__s);} 14707a984708SDavid Chisnall# else 14717a984708SDavid Chisnall {__r_.first().__s.__size_ = (unsigned char)(__s << 1);} 14727a984708SDavid Chisnall# endif 14734bab9fd9SDavid Chisnall 14747a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 14757a984708SDavid Chisnall size_type __get_short_size() const _NOEXCEPT 1476b2c7081bSDimitry Andric# ifdef _LIBCPP_BIG_ENDIAN 14777a984708SDavid Chisnall {return __r_.first().__s.__size_;} 14787a984708SDavid Chisnall# else 14797a984708SDavid Chisnall {return __r_.first().__s.__size_ >> 1;} 14807a984708SDavid Chisnall# endif 14814bab9fd9SDavid Chisnall 14829729cf09SDimitry Andric#endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT 14834bab9fd9SDavid Chisnall 14847a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 14857a984708SDavid Chisnall void __set_long_size(size_type __s) _NOEXCEPT 14867a984708SDavid Chisnall {__r_.first().__l.__size_ = __s;} 14877a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 14887a984708SDavid Chisnall size_type __get_long_size() const _NOEXCEPT 14897a984708SDavid Chisnall {return __r_.first().__l.__size_;} 14907a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 14917a984708SDavid Chisnall void __set_size(size_type __s) _NOEXCEPT 14927a984708SDavid Chisnall {if (__is_long()) __set_long_size(__s); else __set_short_size(__s);} 14937a984708SDavid Chisnall 14947a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 14957a984708SDavid Chisnall void __set_long_cap(size_type __s) _NOEXCEPT 14967a984708SDavid Chisnall {__r_.first().__l.__cap_ = __long_mask | __s;} 14977a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 14987a984708SDavid Chisnall size_type __get_long_cap() const _NOEXCEPT 149994e3ee44SDavid Chisnall {return __r_.first().__l.__cap_ & size_type(~__long_mask);} 15007a984708SDavid Chisnall 15017a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 15027a984708SDavid Chisnall void __set_long_pointer(pointer __p) _NOEXCEPT 15037a984708SDavid Chisnall {__r_.first().__l.__data_ = __p;} 15047a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 15057a984708SDavid Chisnall pointer __get_long_pointer() _NOEXCEPT 15067a984708SDavid Chisnall {return __r_.first().__l.__data_;} 15077a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 15087a984708SDavid Chisnall const_pointer __get_long_pointer() const _NOEXCEPT 15097a984708SDavid Chisnall {return __r_.first().__l.__data_;} 15107a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 15117a984708SDavid Chisnall pointer __get_short_pointer() _NOEXCEPT 15124bab9fd9SDavid Chisnall {return pointer_traits<pointer>::pointer_to(__r_.first().__s.__data_[0]);} 15137a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 15147a984708SDavid Chisnall const_pointer __get_short_pointer() const _NOEXCEPT 15154bab9fd9SDavid Chisnall {return pointer_traits<const_pointer>::pointer_to(__r_.first().__s.__data_[0]);} 15167a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 15177a984708SDavid Chisnall pointer __get_pointer() _NOEXCEPT 15187a984708SDavid Chisnall {return __is_long() ? __get_long_pointer() : __get_short_pointer();} 15197a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 15207a984708SDavid Chisnall const_pointer __get_pointer() const _NOEXCEPT 15217a984708SDavid Chisnall {return __is_long() ? __get_long_pointer() : __get_short_pointer();} 15227a984708SDavid Chisnall 15237a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 15247a984708SDavid Chisnall void __zero() _NOEXCEPT 15257a984708SDavid Chisnall { 15267a984708SDavid Chisnall size_type (&__a)[__n_words] = __r_.first().__r.__words; 15277a984708SDavid Chisnall for (unsigned __i = 0; __i < __n_words; ++__i) 15287a984708SDavid Chisnall __a[__i] = 0; 15297a984708SDavid Chisnall } 15307a984708SDavid Chisnall 15317a984708SDavid Chisnall template <size_type __a> static 15327a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 15334f7ab58eSDimitry Andric size_type __align_it(size_type __s) _NOEXCEPT 1534163c8ab6SDimitry Andric {return (__s + (__a-1)) & ~(__a-1);} 15357a984708SDavid Chisnall enum {__alignment = 16}; 15367a984708SDavid Chisnall static _LIBCPP_INLINE_VISIBILITY 15377a984708SDavid Chisnall size_type __recommend(size_type __s) _NOEXCEPT 15384ba319b5SDimitry Andric { 15394ba319b5SDimitry Andric if (__s < __min_cap) return static_cast<size_type>(__min_cap) - 1; 15404ba319b5SDimitry Andric size_type __guess = __align_it<sizeof(value_type) < __alignment ? 15414ba319b5SDimitry Andric __alignment/sizeof(value_type) : 1 > (__s+1) - 1; 15424ba319b5SDimitry Andric if (__guess == __min_cap) ++__guess; 15434ba319b5SDimitry Andric return __guess; 15444ba319b5SDimitry Andric } 15457a984708SDavid Chisnall 1546540d2a8bSDimitry Andric inline 15474bab9fd9SDavid Chisnall void __init(const value_type* __s, size_type __sz, size_type __reserve); 1548540d2a8bSDimitry Andric inline 15494bab9fd9SDavid Chisnall void __init(const value_type* __s, size_type __sz); 1550540d2a8bSDimitry Andric inline 15517a984708SDavid Chisnall void __init(size_type __n, value_type __c); 15527a984708SDavid Chisnall 15537a984708SDavid Chisnall template <class _InputIterator> 1554540d2a8bSDimitry Andric inline 15557a984708SDavid Chisnall typename enable_if 15567a984708SDavid Chisnall < 15579729cf09SDimitry Andric __is_exactly_input_iterator<_InputIterator>::value, 15587a984708SDavid Chisnall void 15597a984708SDavid Chisnall >::type 15607a984708SDavid Chisnall __init(_InputIterator __first, _InputIterator __last); 15617a984708SDavid Chisnall 15627a984708SDavid Chisnall template <class _ForwardIterator> 1563540d2a8bSDimitry Andric inline 15647a984708SDavid Chisnall typename enable_if 15657a984708SDavid Chisnall < 15667a984708SDavid Chisnall __is_forward_iterator<_ForwardIterator>::value, 15677a984708SDavid Chisnall void 15687a984708SDavid Chisnall >::type 15697a984708SDavid Chisnall __init(_ForwardIterator __first, _ForwardIterator __last); 15707a984708SDavid Chisnall 15717a984708SDavid Chisnall void __grow_by(size_type __old_cap, size_type __delta_cap, size_type __old_sz, 15727a984708SDavid Chisnall size_type __n_copy, size_type __n_del, size_type __n_add = 0); 15737a984708SDavid Chisnall void __grow_by_and_replace(size_type __old_cap, size_type __delta_cap, size_type __old_sz, 15747a984708SDavid Chisnall size_type __n_copy, size_type __n_del, 15754bab9fd9SDavid Chisnall size_type __n_add, const value_type* __p_new_stuff); 15767a984708SDavid Chisnall 15777a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 15787a984708SDavid Chisnall void __erase_to_end(size_type __pos); 15797a984708SDavid Chisnall 15807a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 15817a984708SDavid Chisnall void __copy_assign_alloc(const basic_string& __str) 15827a984708SDavid Chisnall {__copy_assign_alloc(__str, integral_constant<bool, 15837a984708SDavid Chisnall __alloc_traits::propagate_on_container_copy_assignment::value>());} 15847a984708SDavid Chisnall 15857a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 15867a984708SDavid Chisnall void __copy_assign_alloc(const basic_string& __str, true_type) 15877a984708SDavid Chisnall { 1588540d2a8bSDimitry Andric if (__alloc() == __str.__alloc()) 1589540d2a8bSDimitry Andric __alloc() = __str.__alloc(); 1590540d2a8bSDimitry Andric else 1591540d2a8bSDimitry Andric { 1592540d2a8bSDimitry Andric if (!__str.__is_long()) 15937a984708SDavid Chisnall { 15944ba319b5SDimitry Andric __clear_and_shrink(); 15957a984708SDavid Chisnall __alloc() = __str.__alloc(); 15967a984708SDavid Chisnall } 1597540d2a8bSDimitry Andric else 1598540d2a8bSDimitry Andric { 1599540d2a8bSDimitry Andric allocator_type __a = __str.__alloc(); 1600540d2a8bSDimitry Andric pointer __p = __alloc_traits::allocate(__a, __str.__get_long_cap()); 16014ba319b5SDimitry Andric __clear_and_shrink(); 1602540d2a8bSDimitry Andric __alloc() = _VSTD::move(__a); 1603540d2a8bSDimitry Andric __set_long_pointer(__p); 1604540d2a8bSDimitry Andric __set_long_cap(__str.__get_long_cap()); 1605540d2a8bSDimitry Andric __set_long_size(__str.size()); 1606540d2a8bSDimitry Andric } 1607540d2a8bSDimitry Andric } 1608540d2a8bSDimitry Andric } 16097a984708SDavid Chisnall 16107a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 161194e3ee44SDavid Chisnall void __copy_assign_alloc(const basic_string&, false_type) _NOEXCEPT 16127a984708SDavid Chisnall {} 16137a984708SDavid Chisnall 1614540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 16157a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 16169729cf09SDimitry Andric void __move_assign(basic_string& __str, false_type) 16179729cf09SDimitry Andric _NOEXCEPT_(__alloc_traits::is_always_equal::value); 16187a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 16197a984708SDavid Chisnall void __move_assign(basic_string& __str, true_type) 16209729cf09SDimitry Andric#if _LIBCPP_STD_VER > 14 16219729cf09SDimitry Andric _NOEXCEPT; 16229729cf09SDimitry Andric#else 16237a984708SDavid Chisnall _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value); 16247a984708SDavid Chisnall#endif 16259729cf09SDimitry Andric#endif 16267a984708SDavid Chisnall 16277a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 16287a984708SDavid Chisnall void 16297a984708SDavid Chisnall __move_assign_alloc(basic_string& __str) 16307a984708SDavid Chisnall _NOEXCEPT_( 16317a984708SDavid Chisnall !__alloc_traits::propagate_on_container_move_assignment::value || 16327a984708SDavid Chisnall is_nothrow_move_assignable<allocator_type>::value) 16337a984708SDavid Chisnall {__move_assign_alloc(__str, integral_constant<bool, 16347a984708SDavid Chisnall __alloc_traits::propagate_on_container_move_assignment::value>());} 16357a984708SDavid Chisnall 16367a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 16377a984708SDavid Chisnall void __move_assign_alloc(basic_string& __c, true_type) 16387a984708SDavid Chisnall _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) 16397a984708SDavid Chisnall { 16407a984708SDavid Chisnall __alloc() = _VSTD::move(__c.__alloc()); 16417a984708SDavid Chisnall } 16427a984708SDavid Chisnall 16437a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 164494e3ee44SDavid Chisnall void __move_assign_alloc(basic_string&, false_type) 16457a984708SDavid Chisnall _NOEXCEPT 16467a984708SDavid Chisnall {} 16477a984708SDavid Chisnall 16487a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators(); 16497a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(size_type); 16507a984708SDavid Chisnall 16517a984708SDavid Chisnall friend basic_string operator+<>(const basic_string&, const basic_string&); 16527a984708SDavid Chisnall friend basic_string operator+<>(const value_type*, const basic_string&); 16537a984708SDavid Chisnall friend basic_string operator+<>(value_type, const basic_string&); 16547a984708SDavid Chisnall friend basic_string operator+<>(const basic_string&, const value_type*); 16557a984708SDavid Chisnall friend basic_string operator+<>(const basic_string&, value_type); 16567a984708SDavid Chisnall}; 16577a984708SDavid Chisnall 16584ba319b5SDimitry Andric#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES 16594ba319b5SDimitry Andrictemplate<class _InputIterator, 16604ba319b5SDimitry Andric class _CharT = typename iterator_traits<_InputIterator>::value_type, 16614ba319b5SDimitry Andric class _Allocator = allocator<_CharT>, 16624ba319b5SDimitry Andric class = typename enable_if<__is_input_iterator<_InputIterator>::value, void>::type, 16634ba319b5SDimitry Andric class = typename enable_if<__is_allocator<_Allocator>::value, void>::type 16644ba319b5SDimitry Andric > 16654ba319b5SDimitry Andricbasic_string(_InputIterator, _InputIterator, _Allocator = _Allocator()) 16664ba319b5SDimitry Andric -> basic_string<_CharT, char_traits<_CharT>, _Allocator>; 16674ba319b5SDimitry Andric 16684ba319b5SDimitry Andrictemplate<class _CharT, 16694ba319b5SDimitry Andric class _Traits, 16704ba319b5SDimitry Andric class _Allocator = allocator<_CharT>, 16714ba319b5SDimitry Andric class = typename enable_if<__is_allocator<_Allocator>::value, void>::type 16724ba319b5SDimitry Andric > 16734ba319b5SDimitry Andricexplicit basic_string(basic_string_view<_CharT, _Traits>, const _Allocator& = _Allocator()) 16744ba319b5SDimitry Andric -> basic_string<_CharT, _Traits, _Allocator>; 16754ba319b5SDimitry Andric 16764ba319b5SDimitry Andrictemplate<class _CharT, 16774ba319b5SDimitry Andric class _Traits, 16784ba319b5SDimitry Andric class _Allocator = allocator<_CharT>, 16794ba319b5SDimitry Andric class = typename enable_if<__is_allocator<_Allocator>::value, void>::type, 16804ba319b5SDimitry Andric class _Sz = typename allocator_traits<_Allocator>::size_type 16814ba319b5SDimitry Andric > 16824ba319b5SDimitry Andricbasic_string(basic_string_view<_CharT, _Traits>, _Sz, _Sz, const _Allocator& = _Allocator()) 16834ba319b5SDimitry Andric -> basic_string<_CharT, _Traits, _Allocator>; 16844ba319b5SDimitry Andric#endif 16854ba319b5SDimitry Andric 16864ba319b5SDimitry Andric 16877a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 1688*b5893f02SDimitry Andricinline 16897a984708SDavid Chisnallvoid 16907a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::__invalidate_all_iterators() 16917a984708SDavid Chisnall{ 16924f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 16934f7ab58eSDimitry Andric __get_db()->__invalidate_all(this); 16944f7ab58eSDimitry Andric#endif // _LIBCPP_DEBUG_LEVEL >= 2 16957a984708SDavid Chisnall} 16967a984708SDavid Chisnall 16977a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 1698*b5893f02SDimitry Andricinline 16997a984708SDavid Chisnallvoid 170094e3ee44SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type 17014f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 170294e3ee44SDavid Chisnall __pos 170394e3ee44SDavid Chisnall#endif 170494e3ee44SDavid Chisnall ) 17057a984708SDavid Chisnall{ 17064f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 17074f7ab58eSDimitry Andric __c_node* __c = __get_db()->__find_c_and_lock(this); 17084f7ab58eSDimitry Andric if (__c) 17097a984708SDavid Chisnall { 17104f7ab58eSDimitry Andric const_pointer __new_last = __get_pointer() + __pos; 17114f7ab58eSDimitry Andric for (__i_node** __p = __c->end_; __p != __c->beg_; ) 17127a984708SDavid Chisnall { 17134f7ab58eSDimitry Andric --__p; 17144f7ab58eSDimitry Andric const_iterator* __i = static_cast<const_iterator*>((*__p)->__i_); 17154f7ab58eSDimitry Andric if (__i->base() > __new_last) 17167a984708SDavid Chisnall { 17174f7ab58eSDimitry Andric (*__p)->__c_ = nullptr; 17184f7ab58eSDimitry Andric if (--__c->end_ != __p) 17194f7ab58eSDimitry Andric memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*)); 17207a984708SDavid Chisnall } 17217a984708SDavid Chisnall } 17224f7ab58eSDimitry Andric __get_db()->unlock(); 17237a984708SDavid Chisnall } 17244f7ab58eSDimitry Andric#endif // _LIBCPP_DEBUG_LEVEL >= 2 17257a984708SDavid Chisnall} 17267a984708SDavid Chisnall 17277a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 1728*b5893f02SDimitry Andricinline 17297a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::basic_string() 17307a984708SDavid Chisnall _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) 17317a984708SDavid Chisnall{ 17324f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 17334f7ab58eSDimitry Andric __get_db()->__insert_c(this); 17344f7ab58eSDimitry Andric#endif 17357a984708SDavid Chisnall __zero(); 17367a984708SDavid Chisnall} 17377a984708SDavid Chisnall 17387a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 1739*b5893f02SDimitry Andricinline 17407a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::basic_string(const allocator_type& __a) 1741fe9390e7SDimitry Andric#if _LIBCPP_STD_VER <= 14 1742fe9390e7SDimitry Andric _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value) 1743fe9390e7SDimitry Andric#else 1744fe9390e7SDimitry Andric _NOEXCEPT 1745fe9390e7SDimitry Andric#endif 1746540d2a8bSDimitry Andric: __r_(__second_tag(), __a) 17477a984708SDavid Chisnall{ 17484f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 17494f7ab58eSDimitry Andric __get_db()->__insert_c(this); 17504f7ab58eSDimitry Andric#endif 17517a984708SDavid Chisnall __zero(); 17527a984708SDavid Chisnall} 17537a984708SDavid Chisnall 17547a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 1755aed8d94eSDimitry Andricvoid basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, 1756aed8d94eSDimitry Andric size_type __sz, 1757aed8d94eSDimitry Andric size_type __reserve) 17587a984708SDavid Chisnall{ 17597a984708SDavid Chisnall if (__reserve > max_size()) 17607a984708SDavid Chisnall this->__throw_length_error(); 17617a984708SDavid Chisnall pointer __p; 17627a984708SDavid Chisnall if (__reserve < __min_cap) 17637a984708SDavid Chisnall { 17647a984708SDavid Chisnall __set_short_size(__sz); 17657a984708SDavid Chisnall __p = __get_short_pointer(); 17667a984708SDavid Chisnall } 17677a984708SDavid Chisnall else 17687a984708SDavid Chisnall { 17697a984708SDavid Chisnall size_type __cap = __recommend(__reserve); 17707a984708SDavid Chisnall __p = __alloc_traits::allocate(__alloc(), __cap+1); 17717a984708SDavid Chisnall __set_long_pointer(__p); 17727a984708SDavid Chisnall __set_long_cap(__cap+1); 17737a984708SDavid Chisnall __set_long_size(__sz); 17747a984708SDavid Chisnall } 17754bab9fd9SDavid Chisnall traits_type::copy(_VSTD::__to_raw_pointer(__p), __s, __sz); 17767a984708SDavid Chisnall traits_type::assign(__p[__sz], value_type()); 17777a984708SDavid Chisnall} 17787a984708SDavid Chisnall 17797a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 17807a984708SDavid Chisnallvoid 17814bab9fd9SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz) 17827a984708SDavid Chisnall{ 17837a984708SDavid Chisnall if (__sz > max_size()) 17847a984708SDavid Chisnall this->__throw_length_error(); 17857a984708SDavid Chisnall pointer __p; 17867a984708SDavid Chisnall if (__sz < __min_cap) 17877a984708SDavid Chisnall { 17887a984708SDavid Chisnall __set_short_size(__sz); 17897a984708SDavid Chisnall __p = __get_short_pointer(); 17907a984708SDavid Chisnall } 17917a984708SDavid Chisnall else 17927a984708SDavid Chisnall { 17937a984708SDavid Chisnall size_type __cap = __recommend(__sz); 17947a984708SDavid Chisnall __p = __alloc_traits::allocate(__alloc(), __cap+1); 17957a984708SDavid Chisnall __set_long_pointer(__p); 17967a984708SDavid Chisnall __set_long_cap(__cap+1); 17977a984708SDavid Chisnall __set_long_size(__sz); 17987a984708SDavid Chisnall } 17994bab9fd9SDavid Chisnall traits_type::copy(_VSTD::__to_raw_pointer(__p), __s, __sz); 18007a984708SDavid Chisnall traits_type::assign(__p[__sz], value_type()); 18017a984708SDavid Chisnall} 18027a984708SDavid Chisnall 18037a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 1804*b5893f02SDimitry Andric#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES 18054ba319b5SDimitry Andrictemplate <class> 1806*b5893f02SDimitry Andric#endif 1807540d2a8bSDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const _Allocator& __a) 1808540d2a8bSDimitry Andric : __r_(__second_tag(), __a) 18097a984708SDavid Chisnall{ 18104f7ab58eSDimitry Andric _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*, allocator) detected nullptr"); 18117a984708SDavid Chisnall __init(__s, traits_type::length(__s)); 18124f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 18134f7ab58eSDimitry Andric __get_db()->__insert_c(this); 18144f7ab58eSDimitry Andric#endif 18157a984708SDavid Chisnall} 18167a984708SDavid Chisnall 18177a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 1818*b5893f02SDimitry Andricinline 1819540d2a8bSDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_type __n) 18207a984708SDavid Chisnall{ 18214f7ab58eSDimitry Andric _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n) detected nullptr"); 18227a984708SDavid Chisnall __init(__s, __n); 18234f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 18244f7ab58eSDimitry Andric __get_db()->__insert_c(this); 18254f7ab58eSDimitry Andric#endif 18267a984708SDavid Chisnall} 18277a984708SDavid Chisnall 18287a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 1829*b5893f02SDimitry Andricinline 1830540d2a8bSDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_type __n, const _Allocator& __a) 1831540d2a8bSDimitry Andric : __r_(__second_tag(), __a) 18327a984708SDavid Chisnall{ 18334f7ab58eSDimitry Andric _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr"); 18347a984708SDavid Chisnall __init(__s, __n); 18354f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 18364f7ab58eSDimitry Andric __get_db()->__insert_c(this); 18374f7ab58eSDimitry Andric#endif 18387a984708SDavid Chisnall} 18397a984708SDavid Chisnall 18407a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 18417a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str) 1842540d2a8bSDimitry Andric : __r_(__second_tag(), __alloc_traits::select_on_container_copy_construction(__str.__alloc())) 18437a984708SDavid Chisnall{ 18447a984708SDavid Chisnall if (!__str.__is_long()) 18457a984708SDavid Chisnall __r_.first().__r = __str.__r_.first().__r; 18467a984708SDavid Chisnall else 18474bab9fd9SDavid Chisnall __init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size()); 18484f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 18494f7ab58eSDimitry Andric __get_db()->__insert_c(this); 18504f7ab58eSDimitry Andric#endif 18517a984708SDavid Chisnall} 18527a984708SDavid Chisnall 18537a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 1854540d2a8bSDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::basic_string( 1855540d2a8bSDimitry Andric const basic_string& __str, const allocator_type& __a) 1856540d2a8bSDimitry Andric : __r_(__second_tag(), __a) 18577a984708SDavid Chisnall{ 18587a984708SDavid Chisnall if (!__str.__is_long()) 18597a984708SDavid Chisnall __r_.first().__r = __str.__r_.first().__r; 18607a984708SDavid Chisnall else 18614bab9fd9SDavid Chisnall __init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size()); 18624f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 18634f7ab58eSDimitry Andric __get_db()->__insert_c(this); 18644f7ab58eSDimitry Andric#endif 18657a984708SDavid Chisnall} 18667a984708SDavid Chisnall 1867540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 18687a984708SDavid Chisnall 18697a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 1870*b5893f02SDimitry Andricinline 18717a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str) 1872854fa44bSDimitry Andric#if _LIBCPP_STD_VER <= 14 18737a984708SDavid Chisnall _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value) 1874854fa44bSDimitry Andric#else 1875854fa44bSDimitry Andric _NOEXCEPT 1876854fa44bSDimitry Andric#endif 18777a984708SDavid Chisnall : __r_(_VSTD::move(__str.__r_)) 18787a984708SDavid Chisnall{ 18797a984708SDavid Chisnall __str.__zero(); 18804f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 18814f7ab58eSDimitry Andric __get_db()->__insert_c(this); 18824f7ab58eSDimitry Andric if (__is_long()) 18834f7ab58eSDimitry Andric __get_db()->swap(this, &__str); 18847a984708SDavid Chisnall#endif 18857a984708SDavid Chisnall} 18867a984708SDavid Chisnall 18877a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 1888*b5893f02SDimitry Andricinline 18897a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str, const allocator_type& __a) 1890540d2a8bSDimitry Andric : __r_(__second_tag(), __a) 18917a984708SDavid Chisnall{ 1892d72607e9SDimitry Andric if (__str.__is_long() && __a != __str.__alloc()) // copy, not move 18934bab9fd9SDavid Chisnall __init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size()); 1894d72607e9SDimitry Andric else 1895d72607e9SDimitry Andric { 1896d72607e9SDimitry Andric __r_.first().__r = __str.__r_.first().__r; 18977a984708SDavid Chisnall __str.__zero(); 1898d72607e9SDimitry Andric } 18994f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 19004f7ab58eSDimitry Andric __get_db()->__insert_c(this); 19014f7ab58eSDimitry Andric if (__is_long()) 19024f7ab58eSDimitry Andric __get_db()->swap(this, &__str); 19037a984708SDavid Chisnall#endif 19047a984708SDavid Chisnall} 19057a984708SDavid Chisnall 1906540d2a8bSDimitry Andric#endif // _LIBCPP_CXX03_LANG 19077a984708SDavid Chisnall 19087a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 19097a984708SDavid Chisnallvoid 19107a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c) 19117a984708SDavid Chisnall{ 19127a984708SDavid Chisnall if (__n > max_size()) 19137a984708SDavid Chisnall this->__throw_length_error(); 19147a984708SDavid Chisnall pointer __p; 19157a984708SDavid Chisnall if (__n < __min_cap) 19167a984708SDavid Chisnall { 19177a984708SDavid Chisnall __set_short_size(__n); 19187a984708SDavid Chisnall __p = __get_short_pointer(); 19197a984708SDavid Chisnall } 19207a984708SDavid Chisnall else 19217a984708SDavid Chisnall { 19227a984708SDavid Chisnall size_type __cap = __recommend(__n); 19237a984708SDavid Chisnall __p = __alloc_traits::allocate(__alloc(), __cap+1); 19247a984708SDavid Chisnall __set_long_pointer(__p); 19257a984708SDavid Chisnall __set_long_cap(__cap+1); 19267a984708SDavid Chisnall __set_long_size(__n); 19277a984708SDavid Chisnall } 19284bab9fd9SDavid Chisnall traits_type::assign(_VSTD::__to_raw_pointer(__p), __n, __c); 19297a984708SDavid Chisnall traits_type::assign(__p[__n], value_type()); 19307a984708SDavid Chisnall} 19317a984708SDavid Chisnall 19327a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 1933*b5893f02SDimitry Andricinline 1934540d2a8bSDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __c) 19357a984708SDavid Chisnall{ 19367a984708SDavid Chisnall __init(__n, __c); 19374f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 19384f7ab58eSDimitry Andric __get_db()->__insert_c(this); 19394f7ab58eSDimitry Andric#endif 19407a984708SDavid Chisnall} 19417a984708SDavid Chisnall 19427a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 1943*b5893f02SDimitry Andric#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES 19444ba319b5SDimitry Andrictemplate <class> 1945*b5893f02SDimitry Andric#endif 1946540d2a8bSDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __c, const _Allocator& __a) 1947540d2a8bSDimitry Andric : __r_(__second_tag(), __a) 19487a984708SDavid Chisnall{ 19497a984708SDavid Chisnall __init(__n, __c); 19504f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 19514f7ab58eSDimitry Andric __get_db()->__insert_c(this); 19524f7ab58eSDimitry Andric#endif 19537a984708SDavid Chisnall} 19547a984708SDavid Chisnall 19557a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 1956540d2a8bSDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str, 1957540d2a8bSDimitry Andric size_type __pos, size_type __n, 1958540d2a8bSDimitry Andric const _Allocator& __a) 1959540d2a8bSDimitry Andric : __r_(__second_tag(), __a) 19607a984708SDavid Chisnall{ 19617a984708SDavid Chisnall size_type __str_sz = __str.size(); 19627a984708SDavid Chisnall if (__pos > __str_sz) 19637a984708SDavid Chisnall this->__throw_out_of_range(); 19647a984708SDavid Chisnall __init(__str.data() + __pos, _VSTD::min(__n, __str_sz - __pos)); 19654f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 19664f7ab58eSDimitry Andric __get_db()->__insert_c(this); 19674f7ab58eSDimitry Andric#endif 19687a984708SDavid Chisnall} 19697a984708SDavid Chisnall 19707a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 1971*b5893f02SDimitry Andricinline 19727c82a1ecSDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str, size_type __pos, 1973540d2a8bSDimitry Andric const _Allocator& __a) 1974540d2a8bSDimitry Andric : __r_(__second_tag(), __a) 19757c82a1ecSDimitry Andric{ 19767c82a1ecSDimitry Andric size_type __str_sz = __str.size(); 19777c82a1ecSDimitry Andric if (__pos > __str_sz) 19787c82a1ecSDimitry Andric this->__throw_out_of_range(); 19797c82a1ecSDimitry Andric __init(__str.data() + __pos, __str_sz - __pos); 19807c82a1ecSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 19817c82a1ecSDimitry Andric __get_db()->__insert_c(this); 19827c82a1ecSDimitry Andric#endif 19837c82a1ecSDimitry Andric} 19847c82a1ecSDimitry Andric 19857c82a1ecSDimitry Andrictemplate <class _CharT, class _Traits, class _Allocator> 19864ba319b5SDimitry Andrictemplate <class _Tp, class> 1987aed8d94eSDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::basic_string( 19884ba319b5SDimitry Andric const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a) 1989540d2a8bSDimitry Andric : __r_(__second_tag(), __a) 1990aed8d94eSDimitry Andric{ 19914ba319b5SDimitry Andric __self_view __sv0 = __t; 19924ba319b5SDimitry Andric __self_view __sv = __sv0.substr(__pos, __n); 1993aed8d94eSDimitry Andric __init(__sv.data(), __sv.size()); 1994aed8d94eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 1995aed8d94eSDimitry Andric __get_db()->__insert_c(this); 1996aed8d94eSDimitry Andric#endif 1997aed8d94eSDimitry Andric} 1998aed8d94eSDimitry Andric 1999aed8d94eSDimitry Andrictemplate <class _CharT, class _Traits, class _Allocator> 20004ba319b5SDimitry Andrictemplate <class _Tp, class> 20014ba319b5SDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t) 2002aed8d94eSDimitry Andric{ 20034ba319b5SDimitry Andric __self_view __sv = __t; 2004aed8d94eSDimitry Andric __init(__sv.data(), __sv.size()); 2005aed8d94eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 2006aed8d94eSDimitry Andric __get_db()->__insert_c(this); 2007aed8d94eSDimitry Andric#endif 2008aed8d94eSDimitry Andric} 2009aed8d94eSDimitry Andric 2010aed8d94eSDimitry Andrictemplate <class _CharT, class _Traits, class _Allocator> 20114ba319b5SDimitry Andrictemplate <class _Tp, class> 20124ba319b5SDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t, const _Allocator& __a) 2013540d2a8bSDimitry Andric : __r_(__second_tag(), __a) 2014aed8d94eSDimitry Andric{ 20154ba319b5SDimitry Andric __self_view __sv = __t; 2016aed8d94eSDimitry Andric __init(__sv.data(), __sv.size()); 2017aed8d94eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 2018aed8d94eSDimitry Andric __get_db()->__insert_c(this); 2019aed8d94eSDimitry Andric#endif 2020aed8d94eSDimitry Andric} 2021aed8d94eSDimitry Andric 2022aed8d94eSDimitry Andrictemplate <class _CharT, class _Traits, class _Allocator> 20237a984708SDavid Chisnalltemplate <class _InputIterator> 20247a984708SDavid Chisnalltypename enable_if 20257a984708SDavid Chisnall< 20269729cf09SDimitry Andric __is_exactly_input_iterator<_InputIterator>::value, 20277a984708SDavid Chisnall void 20287a984708SDavid Chisnall>::type 20297a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::__init(_InputIterator __first, _InputIterator __last) 20307a984708SDavid Chisnall{ 20317a984708SDavid Chisnall __zero(); 20327a984708SDavid Chisnall#ifndef _LIBCPP_NO_EXCEPTIONS 20337a984708SDavid Chisnall try 20347a984708SDavid Chisnall { 20357a984708SDavid Chisnall#endif // _LIBCPP_NO_EXCEPTIONS 20367a984708SDavid Chisnall for (; __first != __last; ++__first) 20377a984708SDavid Chisnall push_back(*__first); 20387a984708SDavid Chisnall#ifndef _LIBCPP_NO_EXCEPTIONS 20397a984708SDavid Chisnall } 20407a984708SDavid Chisnall catch (...) 20417a984708SDavid Chisnall { 20427a984708SDavid Chisnall if (__is_long()) 20437a984708SDavid Chisnall __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap()); 20447a984708SDavid Chisnall throw; 20457a984708SDavid Chisnall } 20467a984708SDavid Chisnall#endif // _LIBCPP_NO_EXCEPTIONS 20477a984708SDavid Chisnall} 20487a984708SDavid Chisnall 20497a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 20507a984708SDavid Chisnalltemplate <class _ForwardIterator> 20517a984708SDavid Chisnalltypename enable_if 20527a984708SDavid Chisnall< 20537a984708SDavid Chisnall __is_forward_iterator<_ForwardIterator>::value, 20547a984708SDavid Chisnall void 20557a984708SDavid Chisnall>::type 20567a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _ForwardIterator __last) 20577a984708SDavid Chisnall{ 20587a984708SDavid Chisnall size_type __sz = static_cast<size_type>(_VSTD::distance(__first, __last)); 20597a984708SDavid Chisnall if (__sz > max_size()) 20607a984708SDavid Chisnall this->__throw_length_error(); 20617a984708SDavid Chisnall pointer __p; 20627a984708SDavid Chisnall if (__sz < __min_cap) 20637a984708SDavid Chisnall { 20647a984708SDavid Chisnall __set_short_size(__sz); 20657a984708SDavid Chisnall __p = __get_short_pointer(); 20667a984708SDavid Chisnall } 20677a984708SDavid Chisnall else 20687a984708SDavid Chisnall { 20697a984708SDavid Chisnall size_type __cap = __recommend(__sz); 20707a984708SDavid Chisnall __p = __alloc_traits::allocate(__alloc(), __cap+1); 20717a984708SDavid Chisnall __set_long_pointer(__p); 20727a984708SDavid Chisnall __set_long_cap(__cap+1); 20737a984708SDavid Chisnall __set_long_size(__sz); 20747a984708SDavid Chisnall } 2075d72607e9SDimitry Andric for (; __first != __last; ++__first, (void) ++__p) 20767a984708SDavid Chisnall traits_type::assign(*__p, *__first); 20777a984708SDavid Chisnall traits_type::assign(*__p, value_type()); 20787a984708SDavid Chisnall} 20797a984708SDavid Chisnall 20807a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 20817a984708SDavid Chisnalltemplate<class _InputIterator> 2082*b5893f02SDimitry Andricinline 20837a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last) 20847a984708SDavid Chisnall{ 20857a984708SDavid Chisnall __init(__first, __last); 20864f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 20874f7ab58eSDimitry Andric __get_db()->__insert_c(this); 20884f7ab58eSDimitry Andric#endif 20897a984708SDavid Chisnall} 20907a984708SDavid Chisnall 20917a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 20927a984708SDavid Chisnalltemplate<class _InputIterator> 2093*b5893f02SDimitry Andricinline 20947a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last, 20957a984708SDavid Chisnall const allocator_type& __a) 2096540d2a8bSDimitry Andric : __r_(__second_tag(), __a) 20977a984708SDavid Chisnall{ 20987a984708SDavid Chisnall __init(__first, __last); 20994f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 21004f7ab58eSDimitry Andric __get_db()->__insert_c(this); 21014f7ab58eSDimitry Andric#endif 21027a984708SDavid Chisnall} 21037a984708SDavid Chisnall 2104540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 21057a984708SDavid Chisnall 21067a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 2107*b5893f02SDimitry Andricinline 2108540d2a8bSDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::basic_string( 2109540d2a8bSDimitry Andric initializer_list<_CharT> __il) 21107a984708SDavid Chisnall{ 21117a984708SDavid Chisnall __init(__il.begin(), __il.end()); 21124f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 21134f7ab58eSDimitry Andric __get_db()->__insert_c(this); 21144f7ab58eSDimitry Andric#endif 21157a984708SDavid Chisnall} 21167a984708SDavid Chisnall 21177a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 2118*b5893f02SDimitry Andricinline 2119540d2a8bSDimitry Andric 2120540d2a8bSDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::basic_string( 2121540d2a8bSDimitry Andric initializer_list<_CharT> __il, const _Allocator& __a) 2122540d2a8bSDimitry Andric : __r_(__second_tag(), __a) 21237a984708SDavid Chisnall{ 21247a984708SDavid Chisnall __init(__il.begin(), __il.end()); 21254f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 21264f7ab58eSDimitry Andric __get_db()->__insert_c(this); 21274f7ab58eSDimitry Andric#endif 21287a984708SDavid Chisnall} 21297a984708SDavid Chisnall 2130540d2a8bSDimitry Andric#endif // _LIBCPP_CXX03_LANG 21317a984708SDavid Chisnall 21327a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 21337a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::~basic_string() 21347a984708SDavid Chisnall{ 21354f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 21364f7ab58eSDimitry Andric __get_db()->__erase_c(this); 21374f7ab58eSDimitry Andric#endif 21387a984708SDavid Chisnall if (__is_long()) 21397a984708SDavid Chisnall __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap()); 21407a984708SDavid Chisnall} 21417a984708SDavid Chisnall 21427a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 21437a984708SDavid Chisnallvoid 21447a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::__grow_by_and_replace 21457a984708SDavid Chisnall (size_type __old_cap, size_type __delta_cap, size_type __old_sz, 21464bab9fd9SDavid Chisnall size_type __n_copy, size_type __n_del, size_type __n_add, const value_type* __p_new_stuff) 21477a984708SDavid Chisnall{ 21487a984708SDavid Chisnall size_type __ms = max_size(); 21497a984708SDavid Chisnall if (__delta_cap > __ms - __old_cap - 1) 21507a984708SDavid Chisnall this->__throw_length_error(); 21517a984708SDavid Chisnall pointer __old_p = __get_pointer(); 21527a984708SDavid Chisnall size_type __cap = __old_cap < __ms / 2 - __alignment ? 21537a984708SDavid Chisnall __recommend(_VSTD::max(__old_cap + __delta_cap, 2 * __old_cap)) : 21547a984708SDavid Chisnall __ms - 1; 21557a984708SDavid Chisnall pointer __p = __alloc_traits::allocate(__alloc(), __cap+1); 21567a984708SDavid Chisnall __invalidate_all_iterators(); 21577a984708SDavid Chisnall if (__n_copy != 0) 21584bab9fd9SDavid Chisnall traits_type::copy(_VSTD::__to_raw_pointer(__p), 21594bab9fd9SDavid Chisnall _VSTD::__to_raw_pointer(__old_p), __n_copy); 21607a984708SDavid Chisnall if (__n_add != 0) 21614bab9fd9SDavid Chisnall traits_type::copy(_VSTD::__to_raw_pointer(__p) + __n_copy, __p_new_stuff, __n_add); 21627a984708SDavid Chisnall size_type __sec_cp_sz = __old_sz - __n_del - __n_copy; 21637a984708SDavid Chisnall if (__sec_cp_sz != 0) 21644bab9fd9SDavid Chisnall traits_type::copy(_VSTD::__to_raw_pointer(__p) + __n_copy + __n_add, 21654bab9fd9SDavid Chisnall _VSTD::__to_raw_pointer(__old_p) + __n_copy + __n_del, __sec_cp_sz); 21667a984708SDavid Chisnall if (__old_cap+1 != __min_cap) 21677a984708SDavid Chisnall __alloc_traits::deallocate(__alloc(), __old_p, __old_cap+1); 21687a984708SDavid Chisnall __set_long_pointer(__p); 21697a984708SDavid Chisnall __set_long_cap(__cap+1); 21707a984708SDavid Chisnall __old_sz = __n_copy + __n_add + __sec_cp_sz; 21717a984708SDavid Chisnall __set_long_size(__old_sz); 21727a984708SDavid Chisnall traits_type::assign(__p[__old_sz], value_type()); 21737a984708SDavid Chisnall} 21747a984708SDavid Chisnall 21757a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 21767a984708SDavid Chisnallvoid 21777a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::__grow_by(size_type __old_cap, size_type __delta_cap, size_type __old_sz, 21787a984708SDavid Chisnall size_type __n_copy, size_type __n_del, size_type __n_add) 21797a984708SDavid Chisnall{ 21807a984708SDavid Chisnall size_type __ms = max_size(); 21814f7ab58eSDimitry Andric if (__delta_cap > __ms - __old_cap) 21827a984708SDavid Chisnall this->__throw_length_error(); 21837a984708SDavid Chisnall pointer __old_p = __get_pointer(); 21847a984708SDavid Chisnall size_type __cap = __old_cap < __ms / 2 - __alignment ? 21857a984708SDavid Chisnall __recommend(_VSTD::max(__old_cap + __delta_cap, 2 * __old_cap)) : 21867a984708SDavid Chisnall __ms - 1; 21877a984708SDavid Chisnall pointer __p = __alloc_traits::allocate(__alloc(), __cap+1); 21887a984708SDavid Chisnall __invalidate_all_iterators(); 21897a984708SDavid Chisnall if (__n_copy != 0) 21904bab9fd9SDavid Chisnall traits_type::copy(_VSTD::__to_raw_pointer(__p), 21914bab9fd9SDavid Chisnall _VSTD::__to_raw_pointer(__old_p), __n_copy); 21927a984708SDavid Chisnall size_type __sec_cp_sz = __old_sz - __n_del - __n_copy; 21937a984708SDavid Chisnall if (__sec_cp_sz != 0) 21944bab9fd9SDavid Chisnall traits_type::copy(_VSTD::__to_raw_pointer(__p) + __n_copy + __n_add, 21954bab9fd9SDavid Chisnall _VSTD::__to_raw_pointer(__old_p) + __n_copy + __n_del, 21964bab9fd9SDavid Chisnall __sec_cp_sz); 21977a984708SDavid Chisnall if (__old_cap+1 != __min_cap) 21987a984708SDavid Chisnall __alloc_traits::deallocate(__alloc(), __old_p, __old_cap+1); 21997a984708SDavid Chisnall __set_long_pointer(__p); 22007a984708SDavid Chisnall __set_long_cap(__cap+1); 22017a984708SDavid Chisnall} 22027a984708SDavid Chisnall 22037a984708SDavid Chisnall// assign 22047a984708SDavid Chisnall 22057a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 22067a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>& 22074bab9fd9SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_type __n) 22087a984708SDavid Chisnall{ 2209d72607e9SDimitry Andric _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::assign received nullptr"); 22107a984708SDavid Chisnall size_type __cap = capacity(); 22117a984708SDavid Chisnall if (__cap >= __n) 22127a984708SDavid Chisnall { 22134bab9fd9SDavid Chisnall value_type* __p = _VSTD::__to_raw_pointer(__get_pointer()); 22147a984708SDavid Chisnall traits_type::move(__p, __s, __n); 22157a984708SDavid Chisnall traits_type::assign(__p[__n], value_type()); 22167a984708SDavid Chisnall __set_size(__n); 22177a984708SDavid Chisnall __invalidate_iterators_past(__n); 22187a984708SDavid Chisnall } 22197a984708SDavid Chisnall else 22207a984708SDavid Chisnall { 22217a984708SDavid Chisnall size_type __sz = size(); 22227a984708SDavid Chisnall __grow_by_and_replace(__cap, __n - __cap, __sz, 0, __sz, __n, __s); 22237a984708SDavid Chisnall } 22247a984708SDavid Chisnall return *this; 22257a984708SDavid Chisnall} 22267a984708SDavid Chisnall 22277a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 22287a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>& 22297a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c) 22307a984708SDavid Chisnall{ 22317a984708SDavid Chisnall size_type __cap = capacity(); 22327a984708SDavid Chisnall if (__cap < __n) 22337a984708SDavid Chisnall { 22347a984708SDavid Chisnall size_type __sz = size(); 22357a984708SDavid Chisnall __grow_by(__cap, __n - __cap, __sz, 0, __sz); 22367a984708SDavid Chisnall } 22377a984708SDavid Chisnall else 22387a984708SDavid Chisnall __invalidate_iterators_past(__n); 22394bab9fd9SDavid Chisnall value_type* __p = _VSTD::__to_raw_pointer(__get_pointer()); 22407a984708SDavid Chisnall traits_type::assign(__p, __n, __c); 22417a984708SDavid Chisnall traits_type::assign(__p[__n], value_type()); 22427a984708SDavid Chisnall __set_size(__n); 22437a984708SDavid Chisnall return *this; 22447a984708SDavid Chisnall} 22457a984708SDavid Chisnall 22467a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 22477a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>& 22487a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::operator=(value_type __c) 22497a984708SDavid Chisnall{ 22507a984708SDavid Chisnall pointer __p; 22517a984708SDavid Chisnall if (__is_long()) 22527a984708SDavid Chisnall { 22537a984708SDavid Chisnall __p = __get_long_pointer(); 22547a984708SDavid Chisnall __set_long_size(1); 22557a984708SDavid Chisnall } 22567a984708SDavid Chisnall else 22577a984708SDavid Chisnall { 22587a984708SDavid Chisnall __p = __get_short_pointer(); 22597a984708SDavid Chisnall __set_short_size(1); 22607a984708SDavid Chisnall } 22617a984708SDavid Chisnall traits_type::assign(*__p, __c); 22627a984708SDavid Chisnall traits_type::assign(*++__p, value_type()); 22637a984708SDavid Chisnall __invalidate_iterators_past(1); 22647a984708SDavid Chisnall return *this; 22657a984708SDavid Chisnall} 22667a984708SDavid Chisnall 22677a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 22687a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>& 22697a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str) 22707a984708SDavid Chisnall{ 22717a984708SDavid Chisnall if (this != &__str) 22727a984708SDavid Chisnall { 22737a984708SDavid Chisnall __copy_assign_alloc(__str); 22747c82a1ecSDimitry Andric assign(__str.data(), __str.size()); 22757a984708SDavid Chisnall } 22767a984708SDavid Chisnall return *this; 22777a984708SDavid Chisnall} 22787a984708SDavid Chisnall 2279540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 22807a984708SDavid Chisnall 22817a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 2282*b5893f02SDimitry Andricinline 22837a984708SDavid Chisnallvoid 22847a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, false_type) 22859729cf09SDimitry Andric _NOEXCEPT_(__alloc_traits::is_always_equal::value) 22867a984708SDavid Chisnall{ 22877a984708SDavid Chisnall if (__alloc() != __str.__alloc()) 22887a984708SDavid Chisnall assign(__str); 22897a984708SDavid Chisnall else 22907a984708SDavid Chisnall __move_assign(__str, true_type()); 22917a984708SDavid Chisnall} 22927a984708SDavid Chisnall 22937a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 2294*b5893f02SDimitry Andricinline 22957a984708SDavid Chisnallvoid 22967a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, true_type) 22979729cf09SDimitry Andric#if _LIBCPP_STD_VER > 14 22989729cf09SDimitry Andric _NOEXCEPT 22999729cf09SDimitry Andric#else 23007a984708SDavid Chisnall _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) 23019729cf09SDimitry Andric#endif 23027a984708SDavid Chisnall{ 23034ba319b5SDimitry Andric __clear_and_shrink(); 23047a984708SDavid Chisnall __r_.first() = __str.__r_.first(); 23057a984708SDavid Chisnall __move_assign_alloc(__str); 23067a984708SDavid Chisnall __str.__zero(); 23077a984708SDavid Chisnall} 23087a984708SDavid Chisnall 23097a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 2310*b5893f02SDimitry Andricinline 23117a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>& 23127a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::operator=(basic_string&& __str) 23139729cf09SDimitry Andric _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) 23147a984708SDavid Chisnall{ 23157a984708SDavid Chisnall __move_assign(__str, integral_constant<bool, 23167a984708SDavid Chisnall __alloc_traits::propagate_on_container_move_assignment::value>()); 23177a984708SDavid Chisnall return *this; 23187a984708SDavid Chisnall} 23197a984708SDavid Chisnall 23207a984708SDavid Chisnall#endif 23217a984708SDavid Chisnall 23227a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 23237a984708SDavid Chisnalltemplate<class _InputIterator> 23247a984708SDavid Chisnalltypename enable_if 23257a984708SDavid Chisnall< 23269729cf09SDimitry Andric __is_exactly_input_iterator <_InputIterator>::value 23279729cf09SDimitry Andric || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value, 23287a984708SDavid Chisnall basic_string<_CharT, _Traits, _Allocator>& 23297a984708SDavid Chisnall>::type 23307a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::assign(_InputIterator __first, _InputIterator __last) 23317a984708SDavid Chisnall{ 2332aed8d94eSDimitry Andric const basic_string __temp(__first, __last, __alloc()); 23339729cf09SDimitry Andric assign(__temp.data(), __temp.size()); 2334936e9439SDimitry Andric return *this; 23357a984708SDavid Chisnall} 23367a984708SDavid Chisnall 23377a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 23387a984708SDavid Chisnalltemplate<class _ForwardIterator> 23397a984708SDavid Chisnalltypename enable_if 23407a984708SDavid Chisnall< 23419729cf09SDimitry Andric __is_forward_iterator<_ForwardIterator>::value 23429729cf09SDimitry Andric && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value, 23437a984708SDavid Chisnall basic_string<_CharT, _Traits, _Allocator>& 23447a984708SDavid Chisnall>::type 23457a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last) 23467a984708SDavid Chisnall{ 23477a984708SDavid Chisnall size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last)); 23487a984708SDavid Chisnall size_type __cap = capacity(); 23497a984708SDavid Chisnall if (__cap < __n) 23507a984708SDavid Chisnall { 23517a984708SDavid Chisnall size_type __sz = size(); 23527a984708SDavid Chisnall __grow_by(__cap, __n - __cap, __sz, 0, __sz); 23537a984708SDavid Chisnall } 23547a984708SDavid Chisnall else 23557a984708SDavid Chisnall __invalidate_iterators_past(__n); 23567a984708SDavid Chisnall pointer __p = __get_pointer(); 23577a984708SDavid Chisnall for (; __first != __last; ++__first, ++__p) 23587a984708SDavid Chisnall traits_type::assign(*__p, *__first); 23597a984708SDavid Chisnall traits_type::assign(*__p, value_type()); 23607a984708SDavid Chisnall __set_size(__n); 23617a984708SDavid Chisnall return *this; 23627a984708SDavid Chisnall} 23637a984708SDavid Chisnall 23647a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 23657a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>& 23667a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::assign(const basic_string& __str, size_type __pos, size_type __n) 23677a984708SDavid Chisnall{ 23687a984708SDavid Chisnall size_type __sz = __str.size(); 23697a984708SDavid Chisnall if (__pos > __sz) 23707a984708SDavid Chisnall this->__throw_out_of_range(); 23717a984708SDavid Chisnall return assign(__str.data() + __pos, _VSTD::min(__n, __sz - __pos)); 23727a984708SDavid Chisnall} 23737a984708SDavid Chisnall 23747a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 2375aed8d94eSDimitry Andrictemplate <class _Tp> 2376aed8d94eSDimitry Andrictypename enable_if 2377aed8d94eSDimitry Andric< 2378aed8d94eSDimitry Andric __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, 2379aed8d94eSDimitry Andric basic_string<_CharT, _Traits, _Allocator>& 2380aed8d94eSDimitry Andric>::type 2381aed8d94eSDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::assign(const _Tp & __t, size_type __pos, size_type __n) 2382aed8d94eSDimitry Andric{ 2383aed8d94eSDimitry Andric __self_view __sv = __t; 2384aed8d94eSDimitry Andric size_type __sz = __sv.size(); 2385aed8d94eSDimitry Andric if (__pos > __sz) 2386aed8d94eSDimitry Andric this->__throw_out_of_range(); 2387aed8d94eSDimitry Andric return assign(__sv.data() + __pos, _VSTD::min(__n, __sz - __pos)); 2388aed8d94eSDimitry Andric} 2389aed8d94eSDimitry Andric 2390aed8d94eSDimitry Andric 2391aed8d94eSDimitry Andrictemplate <class _CharT, class _Traits, class _Allocator> 23927a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>& 23934bab9fd9SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s) 23947a984708SDavid Chisnall{ 2395d72607e9SDimitry Andric _LIBCPP_ASSERT(__s != nullptr, "string::assign received nullptr"); 23967a984708SDavid Chisnall return assign(__s, traits_type::length(__s)); 23977a984708SDavid Chisnall} 23987a984708SDavid Chisnall 23997a984708SDavid Chisnall// append 24007a984708SDavid Chisnall 24017a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 24027a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>& 24034bab9fd9SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_type __n) 24047a984708SDavid Chisnall{ 2405d72607e9SDimitry Andric _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::append received nullptr"); 24067a984708SDavid Chisnall size_type __cap = capacity(); 24077a984708SDavid Chisnall size_type __sz = size(); 24087a984708SDavid Chisnall if (__cap - __sz >= __n) 24097a984708SDavid Chisnall { 24107a984708SDavid Chisnall if (__n) 24117a984708SDavid Chisnall { 24124bab9fd9SDavid Chisnall value_type* __p = _VSTD::__to_raw_pointer(__get_pointer()); 24137a984708SDavid Chisnall traits_type::copy(__p + __sz, __s, __n); 24147a984708SDavid Chisnall __sz += __n; 24157a984708SDavid Chisnall __set_size(__sz); 24167a984708SDavid Chisnall traits_type::assign(__p[__sz], value_type()); 24177a984708SDavid Chisnall } 24187a984708SDavid Chisnall } 24197a984708SDavid Chisnall else 24207a984708SDavid Chisnall __grow_by_and_replace(__cap, __sz + __n - __cap, __sz, __sz, 0, __n, __s); 24217a984708SDavid Chisnall return *this; 24227a984708SDavid Chisnall} 24237a984708SDavid Chisnall 24247a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 24257a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>& 24267a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::append(size_type __n, value_type __c) 24277a984708SDavid Chisnall{ 24287a984708SDavid Chisnall if (__n) 24297a984708SDavid Chisnall { 24307a984708SDavid Chisnall size_type __cap = capacity(); 24317a984708SDavid Chisnall size_type __sz = size(); 24327a984708SDavid Chisnall if (__cap - __sz < __n) 24337a984708SDavid Chisnall __grow_by(__cap, __sz + __n - __cap, __sz, __sz, 0); 24347a984708SDavid Chisnall pointer __p = __get_pointer(); 24354bab9fd9SDavid Chisnall traits_type::assign(_VSTD::__to_raw_pointer(__p) + __sz, __n, __c); 24367a984708SDavid Chisnall __sz += __n; 24377a984708SDavid Chisnall __set_size(__sz); 24387a984708SDavid Chisnall traits_type::assign(__p[__sz], value_type()); 24397a984708SDavid Chisnall } 24407a984708SDavid Chisnall return *this; 24417a984708SDavid Chisnall} 24427a984708SDavid Chisnall 24437a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 2444*b5893f02SDimitry Andricinline void 2445*b5893f02SDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::__append_default_init(size_type __n) 2446*b5893f02SDimitry Andric{ 2447*b5893f02SDimitry Andric if (__n) 2448*b5893f02SDimitry Andric { 2449*b5893f02SDimitry Andric size_type __cap = capacity(); 2450*b5893f02SDimitry Andric size_type __sz = size(); 2451*b5893f02SDimitry Andric if (__cap - __sz < __n) 2452*b5893f02SDimitry Andric __grow_by(__cap, __sz + __n - __cap, __sz, __sz, 0); 2453*b5893f02SDimitry Andric pointer __p = __get_pointer(); 2454*b5893f02SDimitry Andric __sz += __n; 2455*b5893f02SDimitry Andric __set_size(__sz); 2456*b5893f02SDimitry Andric traits_type::assign(__p[__sz], value_type()); 2457*b5893f02SDimitry Andric } 2458*b5893f02SDimitry Andric} 2459*b5893f02SDimitry Andric 2460*b5893f02SDimitry Andrictemplate <class _CharT, class _Traits, class _Allocator> 24617a984708SDavid Chisnallvoid 24627a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::push_back(value_type __c) 24637a984708SDavid Chisnall{ 24644bab9fd9SDavid Chisnall bool __is_short = !__is_long(); 24654bab9fd9SDavid Chisnall size_type __cap; 24664bab9fd9SDavid Chisnall size_type __sz; 24674bab9fd9SDavid Chisnall if (__is_short) 24684bab9fd9SDavid Chisnall { 24694bab9fd9SDavid Chisnall __cap = __min_cap - 1; 24704bab9fd9SDavid Chisnall __sz = __get_short_size(); 24714bab9fd9SDavid Chisnall } 24724bab9fd9SDavid Chisnall else 24734bab9fd9SDavid Chisnall { 24744bab9fd9SDavid Chisnall __cap = __get_long_cap() - 1; 24754bab9fd9SDavid Chisnall __sz = __get_long_size(); 24764bab9fd9SDavid Chisnall } 24777a984708SDavid Chisnall if (__sz == __cap) 24784bab9fd9SDavid Chisnall { 24797a984708SDavid Chisnall __grow_by(__cap, 1, __sz, __sz, 0); 24804bab9fd9SDavid Chisnall __is_short = !__is_long(); 24814bab9fd9SDavid Chisnall } 24824bab9fd9SDavid Chisnall pointer __p; 24834bab9fd9SDavid Chisnall if (__is_short) 24844bab9fd9SDavid Chisnall { 24854bab9fd9SDavid Chisnall __p = __get_short_pointer() + __sz; 24864bab9fd9SDavid Chisnall __set_short_size(__sz+1); 24874bab9fd9SDavid Chisnall } 24884bab9fd9SDavid Chisnall else 24894bab9fd9SDavid Chisnall { 24904bab9fd9SDavid Chisnall __p = __get_long_pointer() + __sz; 24914bab9fd9SDavid Chisnall __set_long_size(__sz+1); 24924bab9fd9SDavid Chisnall } 24937a984708SDavid Chisnall traits_type::assign(*__p, __c); 24947a984708SDavid Chisnall traits_type::assign(*++__p, value_type()); 24957a984708SDavid Chisnall} 24967a984708SDavid Chisnall 2497aed8d94eSDimitry Andrictemplate <class _Tp> 2498aed8d94eSDimitry Andricbool __ptr_in_range (const _Tp* __p, const _Tp* __first, const _Tp* __last) 24997a984708SDavid Chisnall{ 2500aed8d94eSDimitry Andric return __first <= __p && __p < __last; 2501aed8d94eSDimitry Andric} 2502aed8d94eSDimitry Andric 2503aed8d94eSDimitry Andrictemplate <class _Tp1, class _Tp2> 2504aed8d94eSDimitry Andricbool __ptr_in_range (const _Tp1*, const _Tp2*, const _Tp2*) 2505aed8d94eSDimitry Andric{ 2506aed8d94eSDimitry Andric return false; 25077a984708SDavid Chisnall} 25087a984708SDavid Chisnall 25097a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 25107a984708SDavid Chisnalltemplate<class _ForwardIterator> 25117a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>& 2512aed8d94eSDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::__append_forward_unsafe( 2513aed8d94eSDimitry Andric _ForwardIterator __first, _ForwardIterator __last) 25147a984708SDavid Chisnall{ 2515aed8d94eSDimitry Andric static_assert(__is_forward_iterator<_ForwardIterator>::value, 2516aed8d94eSDimitry Andric "function requires a ForwardIterator"); 25177a984708SDavid Chisnall size_type __sz = size(); 25187a984708SDavid Chisnall size_type __cap = capacity(); 25197a984708SDavid Chisnall size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last)); 25207a984708SDavid Chisnall if (__n) 25217a984708SDavid Chisnall { 2522540d2a8bSDimitry Andric typedef typename iterator_traits<_ForwardIterator>::reference _CharRef; 2523540d2a8bSDimitry Andric _CharRef __tmp_ref = *__first; 2524540d2a8bSDimitry Andric if (__ptr_in_range(_VSTD::addressof(__tmp_ref), data(), data() + size())) 2525aed8d94eSDimitry Andric { 2526aed8d94eSDimitry Andric const basic_string __temp (__first, __last, __alloc()); 2527aed8d94eSDimitry Andric append(__temp.data(), __temp.size()); 2528aed8d94eSDimitry Andric } 2529aed8d94eSDimitry Andric else 2530aed8d94eSDimitry Andric { 25317a984708SDavid Chisnall if (__cap - __sz < __n) 25327a984708SDavid Chisnall __grow_by(__cap, __sz + __n - __cap, __sz, __sz, 0); 25337a984708SDavid Chisnall pointer __p = __get_pointer() + __sz; 25347a984708SDavid Chisnall for (; __first != __last; ++__p, ++__first) 25357a984708SDavid Chisnall traits_type::assign(*__p, *__first); 25367a984708SDavid Chisnall traits_type::assign(*__p, value_type()); 25377a984708SDavid Chisnall __set_size(__sz + __n); 25387a984708SDavid Chisnall } 2539aed8d94eSDimitry Andric } 25407a984708SDavid Chisnall return *this; 25417a984708SDavid Chisnall} 25427a984708SDavid Chisnall 25437a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 2544*b5893f02SDimitry Andricinline 25457a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>& 25467a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str) 25477a984708SDavid Chisnall{ 25487a984708SDavid Chisnall return append(__str.data(), __str.size()); 25497a984708SDavid Chisnall} 25507a984708SDavid Chisnall 25517a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 25527a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>& 25537a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str, size_type __pos, size_type __n) 25547a984708SDavid Chisnall{ 25557a984708SDavid Chisnall size_type __sz = __str.size(); 25567a984708SDavid Chisnall if (__pos > __sz) 25577a984708SDavid Chisnall this->__throw_out_of_range(); 25587a984708SDavid Chisnall return append(__str.data() + __pos, _VSTD::min(__n, __sz - __pos)); 25597a984708SDavid Chisnall} 25607a984708SDavid Chisnall 25617a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 2562aed8d94eSDimitry Andrictemplate <class _Tp> 2563aed8d94eSDimitry Andric typename enable_if 2564aed8d94eSDimitry Andric < 2565aed8d94eSDimitry Andric __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, 2566aed8d94eSDimitry Andric basic_string<_CharT, _Traits, _Allocator>& 2567aed8d94eSDimitry Andric >::type 2568aed8d94eSDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::append(const _Tp & __t, size_type __pos, size_type __n) 2569aed8d94eSDimitry Andric{ 2570aed8d94eSDimitry Andric __self_view __sv = __t; 2571aed8d94eSDimitry Andric size_type __sz = __sv.size(); 2572aed8d94eSDimitry Andric if (__pos > __sz) 2573aed8d94eSDimitry Andric this->__throw_out_of_range(); 2574aed8d94eSDimitry Andric return append(__sv.data() + __pos, _VSTD::min(__n, __sz - __pos)); 2575aed8d94eSDimitry Andric} 2576aed8d94eSDimitry Andric 2577aed8d94eSDimitry Andrictemplate <class _CharT, class _Traits, class _Allocator> 25787a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>& 25794bab9fd9SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s) 25807a984708SDavid Chisnall{ 2581d72607e9SDimitry Andric _LIBCPP_ASSERT(__s != nullptr, "string::append received nullptr"); 25827a984708SDavid Chisnall return append(__s, traits_type::length(__s)); 25837a984708SDavid Chisnall} 25847a984708SDavid Chisnall 25857a984708SDavid Chisnall// insert 25867a984708SDavid Chisnall 25877a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 25887a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>& 25894bab9fd9SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s, size_type __n) 25907a984708SDavid Chisnall{ 2591d72607e9SDimitry Andric _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::insert received nullptr"); 25927a984708SDavid Chisnall size_type __sz = size(); 25937a984708SDavid Chisnall if (__pos > __sz) 25947a984708SDavid Chisnall this->__throw_out_of_range(); 25957a984708SDavid Chisnall size_type __cap = capacity(); 25967a984708SDavid Chisnall if (__cap - __sz >= __n) 25977a984708SDavid Chisnall { 25987a984708SDavid Chisnall if (__n) 25997a984708SDavid Chisnall { 26004bab9fd9SDavid Chisnall value_type* __p = _VSTD::__to_raw_pointer(__get_pointer()); 26017a984708SDavid Chisnall size_type __n_move = __sz - __pos; 26027a984708SDavid Chisnall if (__n_move != 0) 26037a984708SDavid Chisnall { 26047a984708SDavid Chisnall if (__p + __pos <= __s && __s < __p + __sz) 26057a984708SDavid Chisnall __s += __n; 26067a984708SDavid Chisnall traits_type::move(__p + __pos + __n, __p + __pos, __n_move); 26077a984708SDavid Chisnall } 26087a984708SDavid Chisnall traits_type::move(__p + __pos, __s, __n); 26097a984708SDavid Chisnall __sz += __n; 26107a984708SDavid Chisnall __set_size(__sz); 26117a984708SDavid Chisnall traits_type::assign(__p[__sz], value_type()); 26127a984708SDavid Chisnall } 26137a984708SDavid Chisnall } 26147a984708SDavid Chisnall else 26157a984708SDavid Chisnall __grow_by_and_replace(__cap, __sz + __n - __cap, __sz, __pos, 0, __n, __s); 26167a984708SDavid Chisnall return *this; 26177a984708SDavid Chisnall} 26187a984708SDavid Chisnall 26197a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 26207a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>& 26217a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n, value_type __c) 26227a984708SDavid Chisnall{ 26237a984708SDavid Chisnall size_type __sz = size(); 26247a984708SDavid Chisnall if (__pos > __sz) 26257a984708SDavid Chisnall this->__throw_out_of_range(); 26267a984708SDavid Chisnall if (__n) 26277a984708SDavid Chisnall { 26287a984708SDavid Chisnall size_type __cap = capacity(); 26294bab9fd9SDavid Chisnall value_type* __p; 26307a984708SDavid Chisnall if (__cap - __sz >= __n) 26317a984708SDavid Chisnall { 26324bab9fd9SDavid Chisnall __p = _VSTD::__to_raw_pointer(__get_pointer()); 26337a984708SDavid Chisnall size_type __n_move = __sz - __pos; 26347a984708SDavid Chisnall if (__n_move != 0) 26357a984708SDavid Chisnall traits_type::move(__p + __pos + __n, __p + __pos, __n_move); 26367a984708SDavid Chisnall } 26377a984708SDavid Chisnall else 26387a984708SDavid Chisnall { 26397a984708SDavid Chisnall __grow_by(__cap, __sz + __n - __cap, __sz, __pos, 0, __n); 26404bab9fd9SDavid Chisnall __p = _VSTD::__to_raw_pointer(__get_long_pointer()); 26417a984708SDavid Chisnall } 26427a984708SDavid Chisnall traits_type::assign(__p + __pos, __n, __c); 26437a984708SDavid Chisnall __sz += __n; 26447a984708SDavid Chisnall __set_size(__sz); 26457a984708SDavid Chisnall traits_type::assign(__p[__sz], value_type()); 26467a984708SDavid Chisnall } 26477a984708SDavid Chisnall return *this; 26487a984708SDavid Chisnall} 26497a984708SDavid Chisnall 26507a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 26517a984708SDavid Chisnalltemplate<class _InputIterator> 26527a984708SDavid Chisnalltypename enable_if 26537a984708SDavid Chisnall< 26549729cf09SDimitry Andric __is_exactly_input_iterator<_InputIterator>::value 26559729cf09SDimitry Andric || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value, 26567a984708SDavid Chisnall typename basic_string<_CharT, _Traits, _Allocator>::iterator 26577a984708SDavid Chisnall>::type 26587a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIterator __first, _InputIterator __last) 26597a984708SDavid Chisnall{ 26604f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 26614f7ab58eSDimitry Andric _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, 26624f7ab58eSDimitry Andric "string::insert(iterator, range) called with an iterator not" 26634f7ab58eSDimitry Andric " referring to this string"); 26644f7ab58eSDimitry Andric#endif 2665aed8d94eSDimitry Andric const basic_string __temp(__first, __last, __alloc()); 26669729cf09SDimitry Andric return insert(__pos, __temp.data(), __temp.data() + __temp.size()); 26677a984708SDavid Chisnall} 26687a984708SDavid Chisnall 26697a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 26707a984708SDavid Chisnalltemplate<class _ForwardIterator> 26717a984708SDavid Chisnalltypename enable_if 26727a984708SDavid Chisnall< 26739729cf09SDimitry Andric __is_forward_iterator<_ForwardIterator>::value 26749729cf09SDimitry Andric && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value, 26757a984708SDavid Chisnall typename basic_string<_CharT, _Traits, _Allocator>::iterator 26767a984708SDavid Chisnall>::type 26777a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last) 26787a984708SDavid Chisnall{ 26794f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 26804f7ab58eSDimitry Andric _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, 26814f7ab58eSDimitry Andric "string::insert(iterator, range) called with an iterator not" 26824f7ab58eSDimitry Andric " referring to this string"); 26834f7ab58eSDimitry Andric#endif 26847a984708SDavid Chisnall size_type __ip = static_cast<size_type>(__pos - begin()); 26857a984708SDavid Chisnall size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last)); 26867a984708SDavid Chisnall if (__n) 26877a984708SDavid Chisnall { 2688540d2a8bSDimitry Andric typedef typename iterator_traits<_ForwardIterator>::reference _CharRef; 2689540d2a8bSDimitry Andric _CharRef __tmp_char = *__first; 2690540d2a8bSDimitry Andric if (__ptr_in_range(_VSTD::addressof(__tmp_char), data(), data() + size())) 2691aed8d94eSDimitry Andric { 2692aed8d94eSDimitry Andric const basic_string __temp(__first, __last, __alloc()); 2693aed8d94eSDimitry Andric return insert(__pos, __temp.data(), __temp.data() + __temp.size()); 2694aed8d94eSDimitry Andric } 2695aed8d94eSDimitry Andric 2696aed8d94eSDimitry Andric size_type __sz = size(); 2697aed8d94eSDimitry Andric size_type __cap = capacity(); 26984bab9fd9SDavid Chisnall value_type* __p; 26997a984708SDavid Chisnall if (__cap - __sz >= __n) 27007a984708SDavid Chisnall { 27014bab9fd9SDavid Chisnall __p = _VSTD::__to_raw_pointer(__get_pointer()); 27027a984708SDavid Chisnall size_type __n_move = __sz - __ip; 27037a984708SDavid Chisnall if (__n_move != 0) 27047a984708SDavid Chisnall traits_type::move(__p + __ip + __n, __p + __ip, __n_move); 27057a984708SDavid Chisnall } 27067a984708SDavid Chisnall else 27077a984708SDavid Chisnall { 27087a984708SDavid Chisnall __grow_by(__cap, __sz + __n - __cap, __sz, __ip, 0, __n); 27094bab9fd9SDavid Chisnall __p = _VSTD::__to_raw_pointer(__get_long_pointer()); 27107a984708SDavid Chisnall } 27117a984708SDavid Chisnall __sz += __n; 27127a984708SDavid Chisnall __set_size(__sz); 27137a984708SDavid Chisnall traits_type::assign(__p[__sz], value_type()); 27147a984708SDavid Chisnall for (__p += __ip; __first != __last; ++__p, ++__first) 27157a984708SDavid Chisnall traits_type::assign(*__p, *__first); 27167a984708SDavid Chisnall } 27177a984708SDavid Chisnall return begin() + __ip; 27187a984708SDavid Chisnall} 27197a984708SDavid Chisnall 27207a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 2721*b5893f02SDimitry Andricinline 27227a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>& 27237a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_string& __str) 27247a984708SDavid Chisnall{ 27257a984708SDavid Chisnall return insert(__pos1, __str.data(), __str.size()); 27267a984708SDavid Chisnall} 27277a984708SDavid Chisnall 27287a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 27297a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>& 27307a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_string& __str, 27317a984708SDavid Chisnall size_type __pos2, size_type __n) 27327a984708SDavid Chisnall{ 27337a984708SDavid Chisnall size_type __str_sz = __str.size(); 27347a984708SDavid Chisnall if (__pos2 > __str_sz) 27357a984708SDavid Chisnall this->__throw_out_of_range(); 27367a984708SDavid Chisnall return insert(__pos1, __str.data() + __pos2, _VSTD::min(__n, __str_sz - __pos2)); 27377a984708SDavid Chisnall} 27387a984708SDavid Chisnall 27397a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 2740aed8d94eSDimitry Andrictemplate <class _Tp> 2741aed8d94eSDimitry Andrictypename enable_if 2742aed8d94eSDimitry Andric< 2743aed8d94eSDimitry Andric __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, 2744aed8d94eSDimitry Andric basic_string<_CharT, _Traits, _Allocator>& 2745aed8d94eSDimitry Andric>::type 2746aed8d94eSDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const _Tp& __t, 2747aed8d94eSDimitry Andric size_type __pos2, size_type __n) 2748aed8d94eSDimitry Andric{ 2749aed8d94eSDimitry Andric __self_view __sv = __t; 2750aed8d94eSDimitry Andric size_type __str_sz = __sv.size(); 2751aed8d94eSDimitry Andric if (__pos2 > __str_sz) 2752aed8d94eSDimitry Andric this->__throw_out_of_range(); 2753aed8d94eSDimitry Andric return insert(__pos1, __sv.data() + __pos2, _VSTD::min(__n, __str_sz - __pos2)); 2754aed8d94eSDimitry Andric} 2755aed8d94eSDimitry Andric 2756aed8d94eSDimitry Andrictemplate <class _CharT, class _Traits, class _Allocator> 27577a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>& 27584bab9fd9SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s) 27597a984708SDavid Chisnall{ 2760d72607e9SDimitry Andric _LIBCPP_ASSERT(__s != nullptr, "string::insert received nullptr"); 27617a984708SDavid Chisnall return insert(__pos, __s, traits_type::length(__s)); 27627a984708SDavid Chisnall} 27637a984708SDavid Chisnall 27647a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 27657a984708SDavid Chisnalltypename basic_string<_CharT, _Traits, _Allocator>::iterator 27667a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, value_type __c) 27677a984708SDavid Chisnall{ 27687a984708SDavid Chisnall size_type __ip = static_cast<size_type>(__pos - begin()); 27697a984708SDavid Chisnall size_type __sz = size(); 27707a984708SDavid Chisnall size_type __cap = capacity(); 27714bab9fd9SDavid Chisnall value_type* __p; 27727a984708SDavid Chisnall if (__cap == __sz) 27737a984708SDavid Chisnall { 27747a984708SDavid Chisnall __grow_by(__cap, 1, __sz, __ip, 0, 1); 27754bab9fd9SDavid Chisnall __p = _VSTD::__to_raw_pointer(__get_long_pointer()); 27767a984708SDavid Chisnall } 27777a984708SDavid Chisnall else 27787a984708SDavid Chisnall { 27794bab9fd9SDavid Chisnall __p = _VSTD::__to_raw_pointer(__get_pointer()); 27807a984708SDavid Chisnall size_type __n_move = __sz - __ip; 27817a984708SDavid Chisnall if (__n_move != 0) 27827a984708SDavid Chisnall traits_type::move(__p + __ip + 1, __p + __ip, __n_move); 27837a984708SDavid Chisnall } 27847a984708SDavid Chisnall traits_type::assign(__p[__ip], __c); 27857a984708SDavid Chisnall traits_type::assign(__p[++__sz], value_type()); 27867a984708SDavid Chisnall __set_size(__sz); 27877a984708SDavid Chisnall return begin() + static_cast<difference_type>(__ip); 27887a984708SDavid Chisnall} 27897a984708SDavid Chisnall 27907a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 2791*b5893f02SDimitry Andricinline 27927a984708SDavid Chisnalltypename basic_string<_CharT, _Traits, _Allocator>::iterator 27937a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, size_type __n, value_type __c) 27947a984708SDavid Chisnall{ 27954f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 27964f7ab58eSDimitry Andric _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, 27974f7ab58eSDimitry Andric "string::insert(iterator, n, value) called with an iterator not" 27984f7ab58eSDimitry Andric " referring to this string"); 27994f7ab58eSDimitry Andric#endif 28007a984708SDavid Chisnall difference_type __p = __pos - begin(); 28017a984708SDavid Chisnall insert(static_cast<size_type>(__p), __n, __c); 28027a984708SDavid Chisnall return begin() + __p; 28037a984708SDavid Chisnall} 28047a984708SDavid Chisnall 28057a984708SDavid Chisnall// replace 28067a984708SDavid Chisnall 28077a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 28087a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>& 28094bab9fd9SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2) 2810540d2a8bSDimitry Andric _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK 28117a984708SDavid Chisnall{ 2812d72607e9SDimitry Andric _LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::replace received nullptr"); 28137a984708SDavid Chisnall size_type __sz = size(); 28147a984708SDavid Chisnall if (__pos > __sz) 28157a984708SDavid Chisnall this->__throw_out_of_range(); 28167a984708SDavid Chisnall __n1 = _VSTD::min(__n1, __sz - __pos); 28177a984708SDavid Chisnall size_type __cap = capacity(); 28187a984708SDavid Chisnall if (__cap - __sz + __n1 >= __n2) 28197a984708SDavid Chisnall { 28204bab9fd9SDavid Chisnall value_type* __p = _VSTD::__to_raw_pointer(__get_pointer()); 28217a984708SDavid Chisnall if (__n1 != __n2) 28227a984708SDavid Chisnall { 28237a984708SDavid Chisnall size_type __n_move = __sz - __pos - __n1; 28247a984708SDavid Chisnall if (__n_move != 0) 28257a984708SDavid Chisnall { 28267a984708SDavid Chisnall if (__n1 > __n2) 28277a984708SDavid Chisnall { 28287a984708SDavid Chisnall traits_type::move(__p + __pos, __s, __n2); 28297a984708SDavid Chisnall traits_type::move(__p + __pos + __n2, __p + __pos + __n1, __n_move); 28307a984708SDavid Chisnall goto __finish; 28317a984708SDavid Chisnall } 28327a984708SDavid Chisnall if (__p + __pos < __s && __s < __p + __sz) 28337a984708SDavid Chisnall { 28347a984708SDavid Chisnall if (__p + __pos + __n1 <= __s) 28357a984708SDavid Chisnall __s += __n2 - __n1; 28367a984708SDavid Chisnall else // __p + __pos < __s < __p + __pos + __n1 28377a984708SDavid Chisnall { 28387a984708SDavid Chisnall traits_type::move(__p + __pos, __s, __n1); 28397a984708SDavid Chisnall __pos += __n1; 28407a984708SDavid Chisnall __s += __n2; 28417a984708SDavid Chisnall __n2 -= __n1; 28427a984708SDavid Chisnall __n1 = 0; 28437a984708SDavid Chisnall } 28447a984708SDavid Chisnall } 28457a984708SDavid Chisnall traits_type::move(__p + __pos + __n2, __p + __pos + __n1, __n_move); 28467a984708SDavid Chisnall } 28477a984708SDavid Chisnall } 28487a984708SDavid Chisnall traits_type::move(__p + __pos, __s, __n2); 28497a984708SDavid Chisnall__finish: 2850540d2a8bSDimitry Andric// __sz += __n2 - __n1; in this and the below function below can cause unsigned integer overflow, 2851540d2a8bSDimitry Andric// but this is a safe operation, so we disable the check. 28527a984708SDavid Chisnall __sz += __n2 - __n1; 28537a984708SDavid Chisnall __set_size(__sz); 28547a984708SDavid Chisnall __invalidate_iterators_past(__sz); 28557a984708SDavid Chisnall traits_type::assign(__p[__sz], value_type()); 28567a984708SDavid Chisnall } 28577a984708SDavid Chisnall else 28587a984708SDavid Chisnall __grow_by_and_replace(__cap, __sz - __n1 + __n2 - __cap, __sz, __pos, __n1, __n2, __s); 28597a984708SDavid Chisnall return *this; 28607a984708SDavid Chisnall} 28617a984708SDavid Chisnall 28627a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 28637a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>& 28647a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, size_type __n2, value_type __c) 2865540d2a8bSDimitry Andric _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK 28667a984708SDavid Chisnall{ 28677a984708SDavid Chisnall size_type __sz = size(); 28687a984708SDavid Chisnall if (__pos > __sz) 28697a984708SDavid Chisnall this->__throw_out_of_range(); 28707a984708SDavid Chisnall __n1 = _VSTD::min(__n1, __sz - __pos); 28717a984708SDavid Chisnall size_type __cap = capacity(); 28724bab9fd9SDavid Chisnall value_type* __p; 28737a984708SDavid Chisnall if (__cap - __sz + __n1 >= __n2) 28747a984708SDavid Chisnall { 28754bab9fd9SDavid Chisnall __p = _VSTD::__to_raw_pointer(__get_pointer()); 28767a984708SDavid Chisnall if (__n1 != __n2) 28777a984708SDavid Chisnall { 28787a984708SDavid Chisnall size_type __n_move = __sz - __pos - __n1; 28797a984708SDavid Chisnall if (__n_move != 0) 28807a984708SDavid Chisnall traits_type::move(__p + __pos + __n2, __p + __pos + __n1, __n_move); 28817a984708SDavid Chisnall } 28827a984708SDavid Chisnall } 28837a984708SDavid Chisnall else 28847a984708SDavid Chisnall { 28857a984708SDavid Chisnall __grow_by(__cap, __sz - __n1 + __n2 - __cap, __sz, __pos, __n1, __n2); 28864bab9fd9SDavid Chisnall __p = _VSTD::__to_raw_pointer(__get_long_pointer()); 28877a984708SDavid Chisnall } 28887a984708SDavid Chisnall traits_type::assign(__p + __pos, __n2, __c); 28897a984708SDavid Chisnall __sz += __n2 - __n1; 28907a984708SDavid Chisnall __set_size(__sz); 28917a984708SDavid Chisnall __invalidate_iterators_past(__sz); 28927a984708SDavid Chisnall traits_type::assign(__p[__sz], value_type()); 28937a984708SDavid Chisnall return *this; 28947a984708SDavid Chisnall} 28957a984708SDavid Chisnall 28967a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 28977a984708SDavid Chisnalltemplate<class _InputIterator> 28987a984708SDavid Chisnalltypename enable_if 28997a984708SDavid Chisnall< 29007a984708SDavid Chisnall __is_input_iterator<_InputIterator>::value, 29017a984708SDavid Chisnall basic_string<_CharT, _Traits, _Allocator>& 29027a984708SDavid Chisnall>::type 29037a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, 29047a984708SDavid Chisnall _InputIterator __j1, _InputIterator __j2) 29057a984708SDavid Chisnall{ 2906aed8d94eSDimitry Andric const basic_string __temp(__j1, __j2, __alloc()); 29079729cf09SDimitry Andric return this->replace(__i1, __i2, __temp); 29087a984708SDavid Chisnall} 29097a984708SDavid Chisnall 29107a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 2911*b5893f02SDimitry Andricinline 29127a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>& 29137a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const basic_string& __str) 29147a984708SDavid Chisnall{ 29157a984708SDavid Chisnall return replace(__pos1, __n1, __str.data(), __str.size()); 29167a984708SDavid Chisnall} 29177a984708SDavid Chisnall 29187a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 29197a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>& 29207a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const basic_string& __str, 29217a984708SDavid Chisnall size_type __pos2, size_type __n2) 29227a984708SDavid Chisnall{ 29237a984708SDavid Chisnall size_type __str_sz = __str.size(); 29247a984708SDavid Chisnall if (__pos2 > __str_sz) 29257a984708SDavid Chisnall this->__throw_out_of_range(); 29267a984708SDavid Chisnall return replace(__pos1, __n1, __str.data() + __pos2, _VSTD::min(__n2, __str_sz - __pos2)); 29277a984708SDavid Chisnall} 29287a984708SDavid Chisnall 29297a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 2930aed8d94eSDimitry Andrictemplate <class _Tp> 2931aed8d94eSDimitry Andrictypename enable_if 2932aed8d94eSDimitry Andric< 2933aed8d94eSDimitry Andric __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, 2934aed8d94eSDimitry Andric basic_string<_CharT, _Traits, _Allocator>& 2935aed8d94eSDimitry Andric>::type 2936aed8d94eSDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const _Tp& __t, 2937aed8d94eSDimitry Andric size_type __pos2, size_type __n2) 2938aed8d94eSDimitry Andric{ 2939aed8d94eSDimitry Andric __self_view __sv = __t; 2940aed8d94eSDimitry Andric size_type __str_sz = __sv.size(); 2941aed8d94eSDimitry Andric if (__pos2 > __str_sz) 2942aed8d94eSDimitry Andric this->__throw_out_of_range(); 2943aed8d94eSDimitry Andric return replace(__pos1, __n1, __sv.data() + __pos2, _VSTD::min(__n2, __str_sz - __pos2)); 2944aed8d94eSDimitry Andric} 2945aed8d94eSDimitry Andric 2946aed8d94eSDimitry Andrictemplate <class _CharT, class _Traits, class _Allocator> 29477a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>& 29484bab9fd9SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s) 29497a984708SDavid Chisnall{ 2950d72607e9SDimitry Andric _LIBCPP_ASSERT(__s != nullptr, "string::replace received nullptr"); 29517a984708SDavid Chisnall return replace(__pos, __n1, __s, traits_type::length(__s)); 29527a984708SDavid Chisnall} 29537a984708SDavid Chisnall 29547a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 2955*b5893f02SDimitry Andricinline 29567a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>& 29577a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const basic_string& __str) 29587a984708SDavid Chisnall{ 29597a984708SDavid Chisnall return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), 29607a984708SDavid Chisnall __str.data(), __str.size()); 29617a984708SDavid Chisnall} 29627a984708SDavid Chisnall 29637a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 2964*b5893f02SDimitry Andricinline 29657a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>& 29664bab9fd9SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n) 29677a984708SDavid Chisnall{ 29687a984708SDavid Chisnall return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), __s, __n); 29697a984708SDavid Chisnall} 29707a984708SDavid Chisnall 29717a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 2972*b5893f02SDimitry Andricinline 29737a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>& 29744bab9fd9SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const value_type* __s) 29757a984708SDavid Chisnall{ 29767a984708SDavid Chisnall return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), __s); 29777a984708SDavid Chisnall} 29787a984708SDavid Chisnall 29797a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 2980*b5893f02SDimitry Andricinline 29817a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>& 29827a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c) 29837a984708SDavid Chisnall{ 29847a984708SDavid Chisnall return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), __n, __c); 29857a984708SDavid Chisnall} 29867a984708SDavid Chisnall 29877a984708SDavid Chisnall// erase 29887a984708SDavid Chisnall 29897a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 29907a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>& 29917a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos, size_type __n) 29927a984708SDavid Chisnall{ 29937a984708SDavid Chisnall size_type __sz = size(); 29947a984708SDavid Chisnall if (__pos > __sz) 29957a984708SDavid Chisnall this->__throw_out_of_range(); 29967a984708SDavid Chisnall if (__n) 29977a984708SDavid Chisnall { 29984bab9fd9SDavid Chisnall value_type* __p = _VSTD::__to_raw_pointer(__get_pointer()); 29997a984708SDavid Chisnall __n = _VSTD::min(__n, __sz - __pos); 30007a984708SDavid Chisnall size_type __n_move = __sz - __pos - __n; 30017a984708SDavid Chisnall if (__n_move != 0) 30027a984708SDavid Chisnall traits_type::move(__p + __pos, __p + __pos + __n, __n_move); 30037a984708SDavid Chisnall __sz -= __n; 30047a984708SDavid Chisnall __set_size(__sz); 30057a984708SDavid Chisnall __invalidate_iterators_past(__sz); 30067a984708SDavid Chisnall traits_type::assign(__p[__sz], value_type()); 30077a984708SDavid Chisnall } 30087a984708SDavid Chisnall return *this; 30097a984708SDavid Chisnall} 30107a984708SDavid Chisnall 30117a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 3012*b5893f02SDimitry Andricinline 30137a984708SDavid Chisnalltypename basic_string<_CharT, _Traits, _Allocator>::iterator 30147a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __pos) 30157a984708SDavid Chisnall{ 30164f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 30174f7ab58eSDimitry Andric _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, 30184f7ab58eSDimitry Andric "string::erase(iterator) called with an iterator not" 30194f7ab58eSDimitry Andric " referring to this string"); 30204f7ab58eSDimitry Andric#endif 30214f7ab58eSDimitry Andric _LIBCPP_ASSERT(__pos != end(), 30224f7ab58eSDimitry Andric "string::erase(iterator) called with a non-dereferenceable iterator"); 30237a984708SDavid Chisnall iterator __b = begin(); 30247a984708SDavid Chisnall size_type __r = static_cast<size_type>(__pos - __b); 30257a984708SDavid Chisnall erase(__r, 1); 302694e3ee44SDavid Chisnall return __b + static_cast<difference_type>(__r); 30277a984708SDavid Chisnall} 30287a984708SDavid Chisnall 30297a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 3030*b5893f02SDimitry Andricinline 30317a984708SDavid Chisnalltypename basic_string<_CharT, _Traits, _Allocator>::iterator 30327a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __first, const_iterator __last) 30337a984708SDavid Chisnall{ 30344f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 30354f7ab58eSDimitry Andric _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this, 30364f7ab58eSDimitry Andric "string::erase(iterator, iterator) called with an iterator not" 30374f7ab58eSDimitry Andric " referring to this string"); 30384f7ab58eSDimitry Andric#endif 30394f7ab58eSDimitry Andric _LIBCPP_ASSERT(__first <= __last, "string::erase(first, last) called with invalid range"); 30407a984708SDavid Chisnall iterator __b = begin(); 30417a984708SDavid Chisnall size_type __r = static_cast<size_type>(__first - __b); 30427a984708SDavid Chisnall erase(__r, static_cast<size_type>(__last - __first)); 304394e3ee44SDavid Chisnall return __b + static_cast<difference_type>(__r); 30447a984708SDavid Chisnall} 30457a984708SDavid Chisnall 30467a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 3047*b5893f02SDimitry Andricinline 30487a984708SDavid Chisnallvoid 30497a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::pop_back() 30507a984708SDavid Chisnall{ 30514f7ab58eSDimitry Andric _LIBCPP_ASSERT(!empty(), "string::pop_back(): string is already empty"); 30527a984708SDavid Chisnall size_type __sz; 30537a984708SDavid Chisnall if (__is_long()) 30547a984708SDavid Chisnall { 30557a984708SDavid Chisnall __sz = __get_long_size() - 1; 30567a984708SDavid Chisnall __set_long_size(__sz); 30577a984708SDavid Chisnall traits_type::assign(*(__get_long_pointer() + __sz), value_type()); 30587a984708SDavid Chisnall } 30597a984708SDavid Chisnall else 30607a984708SDavid Chisnall { 30617a984708SDavid Chisnall __sz = __get_short_size() - 1; 30627a984708SDavid Chisnall __set_short_size(__sz); 30637a984708SDavid Chisnall traits_type::assign(*(__get_short_pointer() + __sz), value_type()); 30647a984708SDavid Chisnall } 30657a984708SDavid Chisnall __invalidate_iterators_past(__sz); 30667a984708SDavid Chisnall} 30677a984708SDavid Chisnall 30687a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 3069*b5893f02SDimitry Andricinline 30707a984708SDavid Chisnallvoid 30717a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::clear() _NOEXCEPT 30727a984708SDavid Chisnall{ 30737a984708SDavid Chisnall __invalidate_all_iterators(); 30747a984708SDavid Chisnall if (__is_long()) 30757a984708SDavid Chisnall { 30767a984708SDavid Chisnall traits_type::assign(*__get_long_pointer(), value_type()); 30777a984708SDavid Chisnall __set_long_size(0); 30787a984708SDavid Chisnall } 30797a984708SDavid Chisnall else 30807a984708SDavid Chisnall { 30817a984708SDavid Chisnall traits_type::assign(*__get_short_pointer(), value_type()); 30827a984708SDavid Chisnall __set_short_size(0); 30837a984708SDavid Chisnall } 30847a984708SDavid Chisnall} 30857a984708SDavid Chisnall 30867a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 3087*b5893f02SDimitry Andricinline 30887a984708SDavid Chisnallvoid 30897a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::__erase_to_end(size_type __pos) 30907a984708SDavid Chisnall{ 30917a984708SDavid Chisnall if (__is_long()) 30927a984708SDavid Chisnall { 30937a984708SDavid Chisnall traits_type::assign(*(__get_long_pointer() + __pos), value_type()); 30947a984708SDavid Chisnall __set_long_size(__pos); 30957a984708SDavid Chisnall } 30967a984708SDavid Chisnall else 30977a984708SDavid Chisnall { 30987a984708SDavid Chisnall traits_type::assign(*(__get_short_pointer() + __pos), value_type()); 30997a984708SDavid Chisnall __set_short_size(__pos); 31007a984708SDavid Chisnall } 31017a984708SDavid Chisnall __invalidate_iterators_past(__pos); 31027a984708SDavid Chisnall} 31037a984708SDavid Chisnall 31047a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 31057a984708SDavid Chisnallvoid 31067a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::resize(size_type __n, value_type __c) 31077a984708SDavid Chisnall{ 31087a984708SDavid Chisnall size_type __sz = size(); 31097a984708SDavid Chisnall if (__n > __sz) 31107a984708SDavid Chisnall append(__n - __sz, __c); 31117a984708SDavid Chisnall else 31127a984708SDavid Chisnall __erase_to_end(__n); 31137a984708SDavid Chisnall} 31147a984708SDavid Chisnall 31157a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 3116*b5893f02SDimitry Andricinline void 3117*b5893f02SDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::__resize_default_init(size_type __n) 3118*b5893f02SDimitry Andric{ 3119*b5893f02SDimitry Andric size_type __sz = size(); 3120*b5893f02SDimitry Andric if (__n > __sz) { 3121*b5893f02SDimitry Andric __append_default_init(__n - __sz); 3122*b5893f02SDimitry Andric } else 3123*b5893f02SDimitry Andric __erase_to_end(__n); 3124*b5893f02SDimitry Andric} 3125*b5893f02SDimitry Andric 3126*b5893f02SDimitry Andrictemplate <class _CharT, class _Traits, class _Allocator> 3127*b5893f02SDimitry Andricinline 31287a984708SDavid Chisnalltypename basic_string<_CharT, _Traits, _Allocator>::size_type 31297a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::max_size() const _NOEXCEPT 31307a984708SDavid Chisnall{ 31317a984708SDavid Chisnall size_type __m = __alloc_traits::max_size(__alloc()); 3132b2c7081bSDimitry Andric#ifdef _LIBCPP_BIG_ENDIAN 31334f7ab58eSDimitry Andric return (__m <= ~__long_mask ? __m : __m/2) - __alignment; 31347a984708SDavid Chisnall#else 31354f7ab58eSDimitry Andric return __m - __alignment; 31367a984708SDavid Chisnall#endif 31377a984708SDavid Chisnall} 31387a984708SDavid Chisnall 31397a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 31407a984708SDavid Chisnallvoid 31417a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::reserve(size_type __res_arg) 31427a984708SDavid Chisnall{ 31437a984708SDavid Chisnall if (__res_arg > max_size()) 31447a984708SDavid Chisnall this->__throw_length_error(); 31457a984708SDavid Chisnall size_type __cap = capacity(); 31467a984708SDavid Chisnall size_type __sz = size(); 31477a984708SDavid Chisnall __res_arg = _VSTD::max(__res_arg, __sz); 31487a984708SDavid Chisnall __res_arg = __recommend(__res_arg); 31497a984708SDavid Chisnall if (__res_arg != __cap) 31507a984708SDavid Chisnall { 31517a984708SDavid Chisnall pointer __new_data, __p; 31527a984708SDavid Chisnall bool __was_long, __now_long; 31537a984708SDavid Chisnall if (__res_arg == __min_cap - 1) 31547a984708SDavid Chisnall { 31557a984708SDavid Chisnall __was_long = true; 31567a984708SDavid Chisnall __now_long = false; 31577a984708SDavid Chisnall __new_data = __get_short_pointer(); 31587a984708SDavid Chisnall __p = __get_long_pointer(); 31597a984708SDavid Chisnall } 31607a984708SDavid Chisnall else 31617a984708SDavid Chisnall { 31627a984708SDavid Chisnall if (__res_arg > __cap) 31637a984708SDavid Chisnall __new_data = __alloc_traits::allocate(__alloc(), __res_arg+1); 31647a984708SDavid Chisnall else 31657a984708SDavid Chisnall { 31667a984708SDavid Chisnall #ifndef _LIBCPP_NO_EXCEPTIONS 31677a984708SDavid Chisnall try 31687a984708SDavid Chisnall { 31697a984708SDavid Chisnall #endif // _LIBCPP_NO_EXCEPTIONS 31707a984708SDavid Chisnall __new_data = __alloc_traits::allocate(__alloc(), __res_arg+1); 31717a984708SDavid Chisnall #ifndef _LIBCPP_NO_EXCEPTIONS 31727a984708SDavid Chisnall } 31737a984708SDavid Chisnall catch (...) 31747a984708SDavid Chisnall { 31757a984708SDavid Chisnall return; 31767a984708SDavid Chisnall } 31777a984708SDavid Chisnall #else // _LIBCPP_NO_EXCEPTIONS 31784bab9fd9SDavid Chisnall if (__new_data == nullptr) 31797a984708SDavid Chisnall return; 31807a984708SDavid Chisnall #endif // _LIBCPP_NO_EXCEPTIONS 31817a984708SDavid Chisnall } 31827a984708SDavid Chisnall __now_long = true; 31837a984708SDavid Chisnall __was_long = __is_long(); 31847a984708SDavid Chisnall __p = __get_pointer(); 31857a984708SDavid Chisnall } 31864bab9fd9SDavid Chisnall traits_type::copy(_VSTD::__to_raw_pointer(__new_data), 31874bab9fd9SDavid Chisnall _VSTD::__to_raw_pointer(__p), size()+1); 31887a984708SDavid Chisnall if (__was_long) 31897a984708SDavid Chisnall __alloc_traits::deallocate(__alloc(), __p, __cap+1); 31907a984708SDavid Chisnall if (__now_long) 31917a984708SDavid Chisnall { 31927a984708SDavid Chisnall __set_long_cap(__res_arg+1); 31937a984708SDavid Chisnall __set_long_size(__sz); 31947a984708SDavid Chisnall __set_long_pointer(__new_data); 31957a984708SDavid Chisnall } 31967a984708SDavid Chisnall else 31977a984708SDavid Chisnall __set_short_size(__sz); 31987a984708SDavid Chisnall __invalidate_all_iterators(); 31997a984708SDavid Chisnall } 32007a984708SDavid Chisnall} 32017a984708SDavid Chisnall 32027a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 3203*b5893f02SDimitry Andricinline 32047a984708SDavid Chisnalltypename basic_string<_CharT, _Traits, _Allocator>::const_reference 3205aed8d94eSDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) const _NOEXCEPT 32067a984708SDavid Chisnall{ 32074f7ab58eSDimitry Andric _LIBCPP_ASSERT(__pos <= size(), "string index out of bounds"); 32087a984708SDavid Chisnall return *(data() + __pos); 32097a984708SDavid Chisnall} 32107a984708SDavid Chisnall 32117a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 3212*b5893f02SDimitry Andricinline 32137a984708SDavid Chisnalltypename basic_string<_CharT, _Traits, _Allocator>::reference 3214aed8d94eSDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) _NOEXCEPT 32157a984708SDavid Chisnall{ 32164f7ab58eSDimitry Andric _LIBCPP_ASSERT(__pos <= size(), "string index out of bounds"); 32177a984708SDavid Chisnall return *(__get_pointer() + __pos); 32187a984708SDavid Chisnall} 32197a984708SDavid Chisnall 32207a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 32217a984708SDavid Chisnalltypename basic_string<_CharT, _Traits, _Allocator>::const_reference 32227a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::at(size_type __n) const 32237a984708SDavid Chisnall{ 32247a984708SDavid Chisnall if (__n >= size()) 32257a984708SDavid Chisnall this->__throw_out_of_range(); 32267a984708SDavid Chisnall return (*this)[__n]; 32277a984708SDavid Chisnall} 32287a984708SDavid Chisnall 32297a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 32307a984708SDavid Chisnalltypename basic_string<_CharT, _Traits, _Allocator>::reference 32317a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::at(size_type __n) 32327a984708SDavid Chisnall{ 32337a984708SDavid Chisnall if (__n >= size()) 32347a984708SDavid Chisnall this->__throw_out_of_range(); 32357a984708SDavid Chisnall return (*this)[__n]; 32367a984708SDavid Chisnall} 32377a984708SDavid Chisnall 32387a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 3239*b5893f02SDimitry Andricinline 32407a984708SDavid Chisnalltypename basic_string<_CharT, _Traits, _Allocator>::reference 32417a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::front() 32427a984708SDavid Chisnall{ 32434f7ab58eSDimitry Andric _LIBCPP_ASSERT(!empty(), "string::front(): string is empty"); 32447a984708SDavid Chisnall return *__get_pointer(); 32457a984708SDavid Chisnall} 32467a984708SDavid Chisnall 32477a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 3248*b5893f02SDimitry Andricinline 32497a984708SDavid Chisnalltypename basic_string<_CharT, _Traits, _Allocator>::const_reference 32507a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::front() const 32517a984708SDavid Chisnall{ 32524f7ab58eSDimitry Andric _LIBCPP_ASSERT(!empty(), "string::front(): string is empty"); 32537a984708SDavid Chisnall return *data(); 32547a984708SDavid Chisnall} 32557a984708SDavid Chisnall 32567a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 3257*b5893f02SDimitry Andricinline 32587a984708SDavid Chisnalltypename basic_string<_CharT, _Traits, _Allocator>::reference 32597a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::back() 32607a984708SDavid Chisnall{ 32614f7ab58eSDimitry Andric _LIBCPP_ASSERT(!empty(), "string::back(): string is empty"); 32627a984708SDavid Chisnall return *(__get_pointer() + size() - 1); 32637a984708SDavid Chisnall} 32647a984708SDavid Chisnall 32657a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 3266*b5893f02SDimitry Andricinline 32677a984708SDavid Chisnalltypename basic_string<_CharT, _Traits, _Allocator>::const_reference 32687a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::back() const 32697a984708SDavid Chisnall{ 32704f7ab58eSDimitry Andric _LIBCPP_ASSERT(!empty(), "string::back(): string is empty"); 32717a984708SDavid Chisnall return *(data() + size() - 1); 32727a984708SDavid Chisnall} 32737a984708SDavid Chisnall 32747a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 32757a984708SDavid Chisnalltypename basic_string<_CharT, _Traits, _Allocator>::size_type 32764bab9fd9SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::copy(value_type* __s, size_type __n, size_type __pos) const 32777a984708SDavid Chisnall{ 32787a984708SDavid Chisnall size_type __sz = size(); 32797a984708SDavid Chisnall if (__pos > __sz) 32807a984708SDavid Chisnall this->__throw_out_of_range(); 32817a984708SDavid Chisnall size_type __rlen = _VSTD::min(__n, __sz - __pos); 32827a984708SDavid Chisnall traits_type::copy(__s, data() + __pos, __rlen); 32837a984708SDavid Chisnall return __rlen; 32847a984708SDavid Chisnall} 32857a984708SDavid Chisnall 32867a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 3287*b5893f02SDimitry Andricinline 32887a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator> 32897a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::substr(size_type __pos, size_type __n) const 32907a984708SDavid Chisnall{ 32917a984708SDavid Chisnall return basic_string(*this, __pos, __n, __alloc()); 32927a984708SDavid Chisnall} 32937a984708SDavid Chisnall 32947a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 3295*b5893f02SDimitry Andricinline 32967a984708SDavid Chisnallvoid 32977a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str) 3298854fa44bSDimitry Andric#if _LIBCPP_STD_VER >= 14 3299aed8d94eSDimitry Andric _NOEXCEPT_DEBUG 3300854fa44bSDimitry Andric#else 3301aed8d94eSDimitry Andric _NOEXCEPT_DEBUG_(!__alloc_traits::propagate_on_container_swap::value || 33027a984708SDavid Chisnall __is_nothrow_swappable<allocator_type>::value) 3303854fa44bSDimitry Andric#endif 33047a984708SDavid Chisnall{ 33054f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 33064f7ab58eSDimitry Andric if (!__is_long()) 33074f7ab58eSDimitry Andric __get_db()->__invalidate_all(this); 33084f7ab58eSDimitry Andric if (!__str.__is_long()) 33094f7ab58eSDimitry Andric __get_db()->__invalidate_all(&__str); 33104f7ab58eSDimitry Andric __get_db()->swap(this, &__str); 33114f7ab58eSDimitry Andric#endif 3312aed8d94eSDimitry Andric _LIBCPP_ASSERT( 3313aed8d94eSDimitry Andric __alloc_traits::propagate_on_container_swap::value || 3314aed8d94eSDimitry Andric __alloc_traits::is_always_equal::value || 3315aed8d94eSDimitry Andric __alloc() == __str.__alloc(), "swapping non-equal allocators"); 33167a984708SDavid Chisnall _VSTD::swap(__r_.first(), __str.__r_.first()); 3317854fa44bSDimitry Andric __swap_allocator(__alloc(), __str.__alloc()); 33187a984708SDavid Chisnall} 33197a984708SDavid Chisnall 33207a984708SDavid Chisnall// find 33217a984708SDavid Chisnall 33227a984708SDavid Chisnalltemplate <class _Traits> 33237a984708SDavid Chisnallstruct _LIBCPP_HIDDEN __traits_eq 33247a984708SDavid Chisnall{ 33257a984708SDavid Chisnall typedef typename _Traits::char_type char_type; 33267a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 33277a984708SDavid Chisnall bool operator()(const char_type& __x, const char_type& __y) _NOEXCEPT 33287a984708SDavid Chisnall {return _Traits::eq(__x, __y);} 33297a984708SDavid Chisnall}; 33307a984708SDavid Chisnall 33317a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 33327a984708SDavid Chisnalltypename basic_string<_CharT, _Traits, _Allocator>::size_type 33334bab9fd9SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, 33347a984708SDavid Chisnall size_type __pos, 33357a984708SDavid Chisnall size_type __n) const _NOEXCEPT 33367a984708SDavid Chisnall{ 3337d72607e9SDimitry Andric _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find(): received nullptr"); 3338aed8d94eSDimitry Andric return __str_find<value_type, size_type, traits_type, npos> 3339d72607e9SDimitry Andric (data(), size(), __s, __pos, __n); 33407a984708SDavid Chisnall} 33417a984708SDavid Chisnall 33427a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 3343*b5893f02SDimitry Andricinline 33447a984708SDavid Chisnalltypename basic_string<_CharT, _Traits, _Allocator>::size_type 33457a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::find(const basic_string& __str, 33467a984708SDavid Chisnall size_type __pos) const _NOEXCEPT 33477a984708SDavid Chisnall{ 3348aed8d94eSDimitry Andric return __str_find<value_type, size_type, traits_type, npos> 3349d72607e9SDimitry Andric (data(), size(), __str.data(), __pos, __str.size()); 33507a984708SDavid Chisnall} 33517a984708SDavid Chisnall 33527a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 33534ba319b5SDimitry Andrictemplate <class _Tp> 33544ba319b5SDimitry Andrictypename enable_if 33554ba319b5SDimitry Andric< 33564ba319b5SDimitry Andric __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, 33577a984708SDavid Chisnall typename basic_string<_CharT, _Traits, _Allocator>::size_type 33584ba319b5SDimitry Andric>::type 33594ba319b5SDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::find(const _Tp &__t, 33604ba319b5SDimitry Andric size_type __pos) const 3361aed8d94eSDimitry Andric{ 33624ba319b5SDimitry Andric __self_view __sv = __t; 3363aed8d94eSDimitry Andric return __str_find<value_type, size_type, traits_type, npos> 3364aed8d94eSDimitry Andric (data(), size(), __sv.data(), __pos, __sv.size()); 3365aed8d94eSDimitry Andric} 3366aed8d94eSDimitry Andric 3367aed8d94eSDimitry Andrictemplate<class _CharT, class _Traits, class _Allocator> 3368*b5893f02SDimitry Andricinline 3369aed8d94eSDimitry Andrictypename basic_string<_CharT, _Traits, _Allocator>::size_type 33704bab9fd9SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, 33717a984708SDavid Chisnall size_type __pos) const _NOEXCEPT 33727a984708SDavid Chisnall{ 3373d72607e9SDimitry Andric _LIBCPP_ASSERT(__s != nullptr, "string::find(): received nullptr"); 3374aed8d94eSDimitry Andric return __str_find<value_type, size_type, traits_type, npos> 3375d72607e9SDimitry Andric (data(), size(), __s, __pos, traits_type::length(__s)); 33767a984708SDavid Chisnall} 33777a984708SDavid Chisnall 33787a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 33797a984708SDavid Chisnalltypename basic_string<_CharT, _Traits, _Allocator>::size_type 33807a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::find(value_type __c, 33817a984708SDavid Chisnall size_type __pos) const _NOEXCEPT 33827a984708SDavid Chisnall{ 3383aed8d94eSDimitry Andric return __str_find<value_type, size_type, traits_type, npos> 3384d72607e9SDimitry Andric (data(), size(), __c, __pos); 33857a984708SDavid Chisnall} 33867a984708SDavid Chisnall 33877a984708SDavid Chisnall// rfind 33887a984708SDavid Chisnall 33897a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 33907a984708SDavid Chisnalltypename basic_string<_CharT, _Traits, _Allocator>::size_type 33914bab9fd9SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s, 33927a984708SDavid Chisnall size_type __pos, 33937a984708SDavid Chisnall size_type __n) const _NOEXCEPT 33947a984708SDavid Chisnall{ 3395d72607e9SDimitry Andric _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::rfind(): received nullptr"); 3396aed8d94eSDimitry Andric return __str_rfind<value_type, size_type, traits_type, npos> 3397d72607e9SDimitry Andric (data(), size(), __s, __pos, __n); 33987a984708SDavid Chisnall} 33997a984708SDavid Chisnall 34007a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 3401*b5893f02SDimitry Andricinline 34027a984708SDavid Chisnalltypename basic_string<_CharT, _Traits, _Allocator>::size_type 34037a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::rfind(const basic_string& __str, 34047a984708SDavid Chisnall size_type __pos) const _NOEXCEPT 34057a984708SDavid Chisnall{ 3406aed8d94eSDimitry Andric return __str_rfind<value_type, size_type, traits_type, npos> 3407d72607e9SDimitry Andric (data(), size(), __str.data(), __pos, __str.size()); 34087a984708SDavid Chisnall} 34097a984708SDavid Chisnall 34107a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 34114ba319b5SDimitry Andrictemplate <class _Tp> 34124ba319b5SDimitry Andrictypename enable_if 34134ba319b5SDimitry Andric< 34144ba319b5SDimitry Andric __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, 34157a984708SDavid Chisnall typename basic_string<_CharT, _Traits, _Allocator>::size_type 34164ba319b5SDimitry Andric>::type 34174ba319b5SDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::rfind(const _Tp& __t, 34184ba319b5SDimitry Andric size_type __pos) const 3419aed8d94eSDimitry Andric{ 34204ba319b5SDimitry Andric __self_view __sv = __t; 3421aed8d94eSDimitry Andric return __str_rfind<value_type, size_type, traits_type, npos> 3422aed8d94eSDimitry Andric (data(), size(), __sv.data(), __pos, __sv.size()); 3423aed8d94eSDimitry Andric} 3424aed8d94eSDimitry Andric 3425aed8d94eSDimitry Andrictemplate<class _CharT, class _Traits, class _Allocator> 3426*b5893f02SDimitry Andricinline 3427aed8d94eSDimitry Andrictypename basic_string<_CharT, _Traits, _Allocator>::size_type 34284bab9fd9SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s, 34297a984708SDavid Chisnall size_type __pos) const _NOEXCEPT 34307a984708SDavid Chisnall{ 3431d72607e9SDimitry Andric _LIBCPP_ASSERT(__s != nullptr, "string::rfind(): received nullptr"); 3432aed8d94eSDimitry Andric return __str_rfind<value_type, size_type, traits_type, npos> 3433d72607e9SDimitry Andric (data(), size(), __s, __pos, traits_type::length(__s)); 34347a984708SDavid Chisnall} 34357a984708SDavid Chisnall 34367a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 34377a984708SDavid Chisnalltypename basic_string<_CharT, _Traits, _Allocator>::size_type 34387a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::rfind(value_type __c, 34397a984708SDavid Chisnall size_type __pos) const _NOEXCEPT 34407a984708SDavid Chisnall{ 3441aed8d94eSDimitry Andric return __str_rfind<value_type, size_type, traits_type, npos> 3442d72607e9SDimitry Andric (data(), size(), __c, __pos); 34437a984708SDavid Chisnall} 34447a984708SDavid Chisnall 34457a984708SDavid Chisnall// find_first_of 34467a984708SDavid Chisnall 34477a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 34487a984708SDavid Chisnalltypename basic_string<_CharT, _Traits, _Allocator>::size_type 34494bab9fd9SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s, 34507a984708SDavid Chisnall size_type __pos, 34517a984708SDavid Chisnall size_type __n) const _NOEXCEPT 34527a984708SDavid Chisnall{ 3453d72607e9SDimitry Andric _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_of(): received nullptr"); 3454aed8d94eSDimitry Andric return __str_find_first_of<value_type, size_type, traits_type, npos> 3455d72607e9SDimitry Andric (data(), size(), __s, __pos, __n); 34567a984708SDavid Chisnall} 34577a984708SDavid Chisnall 34587a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 3459*b5893f02SDimitry Andricinline 34607a984708SDavid Chisnalltypename basic_string<_CharT, _Traits, _Allocator>::size_type 34617a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::find_first_of(const basic_string& __str, 34627a984708SDavid Chisnall size_type __pos) const _NOEXCEPT 34637a984708SDavid Chisnall{ 3464aed8d94eSDimitry Andric return __str_find_first_of<value_type, size_type, traits_type, npos> 3465d72607e9SDimitry Andric (data(), size(), __str.data(), __pos, __str.size()); 34667a984708SDavid Chisnall} 34677a984708SDavid Chisnall 34687a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 34694ba319b5SDimitry Andrictemplate <class _Tp> 34704ba319b5SDimitry Andrictypename enable_if 34714ba319b5SDimitry Andric< 34724ba319b5SDimitry Andric __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, 34737a984708SDavid Chisnall typename basic_string<_CharT, _Traits, _Allocator>::size_type 34744ba319b5SDimitry Andric>::type 34754ba319b5SDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::find_first_of(const _Tp& __t, 34764ba319b5SDimitry Andric size_type __pos) const 3477aed8d94eSDimitry Andric{ 34784ba319b5SDimitry Andric __self_view __sv = __t; 3479aed8d94eSDimitry Andric return __str_find_first_of<value_type, size_type, traits_type, npos> 3480aed8d94eSDimitry Andric (data(), size(), __sv.data(), __pos, __sv.size()); 3481aed8d94eSDimitry Andric} 3482aed8d94eSDimitry Andric 3483aed8d94eSDimitry Andrictemplate<class _CharT, class _Traits, class _Allocator> 3484*b5893f02SDimitry Andricinline 3485aed8d94eSDimitry Andrictypename basic_string<_CharT, _Traits, _Allocator>::size_type 34864bab9fd9SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s, 34877a984708SDavid Chisnall size_type __pos) const _NOEXCEPT 34887a984708SDavid Chisnall{ 3489d72607e9SDimitry Andric _LIBCPP_ASSERT(__s != nullptr, "string::find_first_of(): received nullptr"); 3490aed8d94eSDimitry Andric return __str_find_first_of<value_type, size_type, traits_type, npos> 3491d72607e9SDimitry Andric (data(), size(), __s, __pos, traits_type::length(__s)); 34927a984708SDavid Chisnall} 34937a984708SDavid Chisnall 34947a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 3495*b5893f02SDimitry Andricinline 34967a984708SDavid Chisnalltypename basic_string<_CharT, _Traits, _Allocator>::size_type 34977a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::find_first_of(value_type __c, 34987a984708SDavid Chisnall size_type __pos) const _NOEXCEPT 34997a984708SDavid Chisnall{ 35007a984708SDavid Chisnall return find(__c, __pos); 35017a984708SDavid Chisnall} 35027a984708SDavid Chisnall 35037a984708SDavid Chisnall// find_last_of 35047a984708SDavid Chisnall 35057a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 35067a984708SDavid Chisnalltypename basic_string<_CharT, _Traits, _Allocator>::size_type 35074bab9fd9SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s, 35087a984708SDavid Chisnall size_type __pos, 35097a984708SDavid Chisnall size_type __n) const _NOEXCEPT 35107a984708SDavid Chisnall{ 3511d72607e9SDimitry Andric _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_of(): received nullptr"); 3512aed8d94eSDimitry Andric return __str_find_last_of<value_type, size_type, traits_type, npos> 3513d72607e9SDimitry Andric (data(), size(), __s, __pos, __n); 35147a984708SDavid Chisnall} 35157a984708SDavid Chisnall 35167a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 3517*b5893f02SDimitry Andricinline 35187a984708SDavid Chisnalltypename basic_string<_CharT, _Traits, _Allocator>::size_type 35197a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::find_last_of(const basic_string& __str, 35207a984708SDavid Chisnall size_type __pos) const _NOEXCEPT 35217a984708SDavid Chisnall{ 3522aed8d94eSDimitry Andric return __str_find_last_of<value_type, size_type, traits_type, npos> 3523d72607e9SDimitry Andric (data(), size(), __str.data(), __pos, __str.size()); 35247a984708SDavid Chisnall} 35257a984708SDavid Chisnall 35267a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 35274ba319b5SDimitry Andrictemplate <class _Tp> 35284ba319b5SDimitry Andrictypename enable_if 35294ba319b5SDimitry Andric< 35304ba319b5SDimitry Andric __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, 35317a984708SDavid Chisnall typename basic_string<_CharT, _Traits, _Allocator>::size_type 35324ba319b5SDimitry Andric>::type 35334ba319b5SDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::find_last_of(const _Tp& __t, 35344ba319b5SDimitry Andric size_type __pos) const 3535aed8d94eSDimitry Andric{ 35364ba319b5SDimitry Andric __self_view __sv = __t; 3537aed8d94eSDimitry Andric return __str_find_last_of<value_type, size_type, traits_type, npos> 3538aed8d94eSDimitry Andric (data(), size(), __sv.data(), __pos, __sv.size()); 3539aed8d94eSDimitry Andric} 3540aed8d94eSDimitry Andric 3541aed8d94eSDimitry Andrictemplate<class _CharT, class _Traits, class _Allocator> 3542*b5893f02SDimitry Andricinline 3543aed8d94eSDimitry Andrictypename basic_string<_CharT, _Traits, _Allocator>::size_type 35444bab9fd9SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s, 35457a984708SDavid Chisnall size_type __pos) const _NOEXCEPT 35467a984708SDavid Chisnall{ 3547d72607e9SDimitry Andric _LIBCPP_ASSERT(__s != nullptr, "string::find_last_of(): received nullptr"); 3548aed8d94eSDimitry Andric return __str_find_last_of<value_type, size_type, traits_type, npos> 3549d72607e9SDimitry Andric (data(), size(), __s, __pos, traits_type::length(__s)); 35507a984708SDavid Chisnall} 35517a984708SDavid Chisnall 35527a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 3553*b5893f02SDimitry Andricinline 35547a984708SDavid Chisnalltypename basic_string<_CharT, _Traits, _Allocator>::size_type 35557a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::find_last_of(value_type __c, 35567a984708SDavid Chisnall size_type __pos) const _NOEXCEPT 35577a984708SDavid Chisnall{ 35587a984708SDavid Chisnall return rfind(__c, __pos); 35597a984708SDavid Chisnall} 35607a984708SDavid Chisnall 35617a984708SDavid Chisnall// find_first_not_of 35627a984708SDavid Chisnall 35637a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 35647a984708SDavid Chisnalltypename basic_string<_CharT, _Traits, _Allocator>::size_type 35654bab9fd9SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s, 35667a984708SDavid Chisnall size_type __pos, 35677a984708SDavid Chisnall size_type __n) const _NOEXCEPT 35687a984708SDavid Chisnall{ 3569d72607e9SDimitry Andric _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_not_of(): received nullptr"); 3570aed8d94eSDimitry Andric return __str_find_first_not_of<value_type, size_type, traits_type, npos> 3571d72607e9SDimitry Andric (data(), size(), __s, __pos, __n); 35727a984708SDavid Chisnall} 35737a984708SDavid Chisnall 35747a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 3575*b5893f02SDimitry Andricinline 35767a984708SDavid Chisnalltypename basic_string<_CharT, _Traits, _Allocator>::size_type 35777a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const basic_string& __str, 35787a984708SDavid Chisnall size_type __pos) const _NOEXCEPT 35797a984708SDavid Chisnall{ 3580aed8d94eSDimitry Andric return __str_find_first_not_of<value_type, size_type, traits_type, npos> 3581d72607e9SDimitry Andric (data(), size(), __str.data(), __pos, __str.size()); 35827a984708SDavid Chisnall} 35837a984708SDavid Chisnall 35847a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 35854ba319b5SDimitry Andrictemplate <class _Tp> 35864ba319b5SDimitry Andrictypename enable_if 35874ba319b5SDimitry Andric< 35884ba319b5SDimitry Andric __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, 35897a984708SDavid Chisnall typename basic_string<_CharT, _Traits, _Allocator>::size_type 35904ba319b5SDimitry Andric>::type 35914ba319b5SDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const _Tp& __t, 35924ba319b5SDimitry Andric size_type __pos) const 3593aed8d94eSDimitry Andric{ 35944ba319b5SDimitry Andric __self_view __sv = __t; 3595aed8d94eSDimitry Andric return __str_find_first_not_of<value_type, size_type, traits_type, npos> 3596aed8d94eSDimitry Andric (data(), size(), __sv.data(), __pos, __sv.size()); 3597aed8d94eSDimitry Andric} 3598aed8d94eSDimitry Andric 3599aed8d94eSDimitry Andrictemplate<class _CharT, class _Traits, class _Allocator> 3600*b5893f02SDimitry Andricinline 3601aed8d94eSDimitry Andrictypename basic_string<_CharT, _Traits, _Allocator>::size_type 36024bab9fd9SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s, 36037a984708SDavid Chisnall size_type __pos) const _NOEXCEPT 36047a984708SDavid Chisnall{ 3605d72607e9SDimitry Andric _LIBCPP_ASSERT(__s != nullptr, "string::find_first_not_of(): received nullptr"); 3606aed8d94eSDimitry Andric return __str_find_first_not_of<value_type, size_type, traits_type, npos> 3607d72607e9SDimitry Andric (data(), size(), __s, __pos, traits_type::length(__s)); 36087a984708SDavid Chisnall} 36097a984708SDavid Chisnall 36107a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 3611*b5893f02SDimitry Andricinline 36127a984708SDavid Chisnalltypename basic_string<_CharT, _Traits, _Allocator>::size_type 36137a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::find_first_not_of(value_type __c, 36147a984708SDavid Chisnall size_type __pos) const _NOEXCEPT 36157a984708SDavid Chisnall{ 3616aed8d94eSDimitry Andric return __str_find_first_not_of<value_type, size_type, traits_type, npos> 3617d72607e9SDimitry Andric (data(), size(), __c, __pos); 36187a984708SDavid Chisnall} 36197a984708SDavid Chisnall 36207a984708SDavid Chisnall// find_last_not_of 36217a984708SDavid Chisnall 36227a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 36237a984708SDavid Chisnalltypename basic_string<_CharT, _Traits, _Allocator>::size_type 36244bab9fd9SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s, 36257a984708SDavid Chisnall size_type __pos, 36267a984708SDavid Chisnall size_type __n) const _NOEXCEPT 36277a984708SDavid Chisnall{ 3628d72607e9SDimitry Andric _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_not_of(): received nullptr"); 3629aed8d94eSDimitry Andric return __str_find_last_not_of<value_type, size_type, traits_type, npos> 3630d72607e9SDimitry Andric (data(), size(), __s, __pos, __n); 36317a984708SDavid Chisnall} 36327a984708SDavid Chisnall 36337a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 3634*b5893f02SDimitry Andricinline 36357a984708SDavid Chisnalltypename basic_string<_CharT, _Traits, _Allocator>::size_type 36367a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const basic_string& __str, 36377a984708SDavid Chisnall size_type __pos) const _NOEXCEPT 36387a984708SDavid Chisnall{ 3639aed8d94eSDimitry Andric return __str_find_last_not_of<value_type, size_type, traits_type, npos> 3640d72607e9SDimitry Andric (data(), size(), __str.data(), __pos, __str.size()); 36417a984708SDavid Chisnall} 36427a984708SDavid Chisnall 36437a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 36444ba319b5SDimitry Andrictemplate <class _Tp> 36454ba319b5SDimitry Andrictypename enable_if 36464ba319b5SDimitry Andric< 36474ba319b5SDimitry Andric __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, 36487a984708SDavid Chisnall typename basic_string<_CharT, _Traits, _Allocator>::size_type 36494ba319b5SDimitry Andric>::type 36504ba319b5SDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const _Tp& __t, 36514ba319b5SDimitry Andric size_type __pos) const 3652aed8d94eSDimitry Andric{ 36534ba319b5SDimitry Andric __self_view __sv = __t; 3654aed8d94eSDimitry Andric return __str_find_last_not_of<value_type, size_type, traits_type, npos> 3655aed8d94eSDimitry Andric (data(), size(), __sv.data(), __pos, __sv.size()); 3656aed8d94eSDimitry Andric} 3657aed8d94eSDimitry Andric 3658aed8d94eSDimitry Andrictemplate<class _CharT, class _Traits, class _Allocator> 3659*b5893f02SDimitry Andricinline 3660aed8d94eSDimitry Andrictypename basic_string<_CharT, _Traits, _Allocator>::size_type 36614bab9fd9SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s, 36627a984708SDavid Chisnall size_type __pos) const _NOEXCEPT 36637a984708SDavid Chisnall{ 3664d72607e9SDimitry Andric _LIBCPP_ASSERT(__s != nullptr, "string::find_last_not_of(): received nullptr"); 3665aed8d94eSDimitry Andric return __str_find_last_not_of<value_type, size_type, traits_type, npos> 3666d72607e9SDimitry Andric (data(), size(), __s, __pos, traits_type::length(__s)); 36677a984708SDavid Chisnall} 36687a984708SDavid Chisnall 36697a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 3670*b5893f02SDimitry Andricinline 36717a984708SDavid Chisnalltypename basic_string<_CharT, _Traits, _Allocator>::size_type 36727a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c, 36737a984708SDavid Chisnall size_type __pos) const _NOEXCEPT 36747a984708SDavid Chisnall{ 3675aed8d94eSDimitry Andric return __str_find_last_not_of<value_type, size_type, traits_type, npos> 3676d72607e9SDimitry Andric (data(), size(), __c, __pos); 36777a984708SDavid Chisnall} 36787a984708SDavid Chisnall 36797a984708SDavid Chisnall// compare 36807a984708SDavid Chisnall 36817a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 36824ba319b5SDimitry Andrictemplate <class _Tp> 36834ba319b5SDimitry Andrictypename enable_if 36844ba319b5SDimitry Andric< 36854ba319b5SDimitry Andric __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, 36867a984708SDavid Chisnall int 36874ba319b5SDimitry Andric>::type 36884ba319b5SDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::compare(const _Tp& __t) const 36897a984708SDavid Chisnall{ 36904ba319b5SDimitry Andric __self_view __sv = __t; 36917a984708SDavid Chisnall size_t __lhs_sz = size(); 3692aed8d94eSDimitry Andric size_t __rhs_sz = __sv.size(); 3693aed8d94eSDimitry Andric int __result = traits_type::compare(data(), __sv.data(), 36947a984708SDavid Chisnall _VSTD::min(__lhs_sz, __rhs_sz)); 36957a984708SDavid Chisnall if (__result != 0) 36967a984708SDavid Chisnall return __result; 36977a984708SDavid Chisnall if (__lhs_sz < __rhs_sz) 36987a984708SDavid Chisnall return -1; 36997a984708SDavid Chisnall if (__lhs_sz > __rhs_sz) 37007a984708SDavid Chisnall return 1; 37017a984708SDavid Chisnall return 0; 37027a984708SDavid Chisnall} 37037a984708SDavid Chisnall 37047a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 3705*b5893f02SDimitry Andricinline 37067a984708SDavid Chisnallint 3707aed8d94eSDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::compare(const basic_string& __str) const _NOEXCEPT 37087a984708SDavid Chisnall{ 3709aed8d94eSDimitry Andric return compare(__self_view(__str)); 37107a984708SDavid Chisnall} 37117a984708SDavid Chisnall 37127a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 37137a984708SDavid Chisnallint 37147a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, 37157a984708SDavid Chisnall size_type __n1, 37164bab9fd9SDavid Chisnall const value_type* __s, 37177a984708SDavid Chisnall size_type __n2) const 37187a984708SDavid Chisnall{ 3719d72607e9SDimitry Andric _LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::compare(): received nullptr"); 37207a984708SDavid Chisnall size_type __sz = size(); 37217a984708SDavid Chisnall if (__pos1 > __sz || __n2 == npos) 37227a984708SDavid Chisnall this->__throw_out_of_range(); 37237a984708SDavid Chisnall size_type __rlen = _VSTD::min(__n1, __sz - __pos1); 37247a984708SDavid Chisnall int __r = traits_type::compare(data() + __pos1, __s, _VSTD::min(__rlen, __n2)); 37257a984708SDavid Chisnall if (__r == 0) 37267a984708SDavid Chisnall { 37277a984708SDavid Chisnall if (__rlen < __n2) 37287a984708SDavid Chisnall __r = -1; 37297a984708SDavid Chisnall else if (__rlen > __n2) 37307a984708SDavid Chisnall __r = 1; 37317a984708SDavid Chisnall } 37327a984708SDavid Chisnall return __r; 37337a984708SDavid Chisnall} 37347a984708SDavid Chisnall 3735aed8d94eSDimitry Andrictemplate <class _CharT, class _Traits, class _Allocator> 37364ba319b5SDimitry Andrictemplate <class _Tp> 37374ba319b5SDimitry Andrictypename enable_if 37384ba319b5SDimitry Andric< 37394ba319b5SDimitry Andric __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, 3740aed8d94eSDimitry Andric int 37414ba319b5SDimitry Andric>::type 3742aed8d94eSDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, 3743aed8d94eSDimitry Andric size_type __n1, 37444ba319b5SDimitry Andric const _Tp& __t) const 3745aed8d94eSDimitry Andric{ 37464ba319b5SDimitry Andric __self_view __sv = __t; 3747aed8d94eSDimitry Andric return compare(__pos1, __n1, __sv.data(), __sv.size()); 3748aed8d94eSDimitry Andric} 3749aed8d94eSDimitry Andric 3750aed8d94eSDimitry Andrictemplate <class _CharT, class _Traits, class _Allocator> 3751*b5893f02SDimitry Andricinline 3752aed8d94eSDimitry Andricint 3753aed8d94eSDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, 3754aed8d94eSDimitry Andric size_type __n1, 3755aed8d94eSDimitry Andric const basic_string& __str) const 3756aed8d94eSDimitry Andric{ 3757aed8d94eSDimitry Andric return compare(__pos1, __n1, __str.data(), __str.size()); 3758aed8d94eSDimitry Andric} 3759aed8d94eSDimitry Andric 3760aed8d94eSDimitry Andrictemplate <class _CharT, class _Traits, class _Allocator> 3761aed8d94eSDimitry Andrictemplate <class _Tp> 3762aed8d94eSDimitry Andrictypename enable_if 3763aed8d94eSDimitry Andric< 3764aed8d94eSDimitry Andric __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, 3765aed8d94eSDimitry Andric int 3766aed8d94eSDimitry Andric>::type 3767aed8d94eSDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, 3768aed8d94eSDimitry Andric size_type __n1, 3769aed8d94eSDimitry Andric const _Tp& __t, 3770aed8d94eSDimitry Andric size_type __pos2, 3771aed8d94eSDimitry Andric size_type __n2) const 3772aed8d94eSDimitry Andric{ 3773aed8d94eSDimitry Andric __self_view __sv = __t; 3774aed8d94eSDimitry Andric return __self_view(*this).substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2)); 3775aed8d94eSDimitry Andric} 3776aed8d94eSDimitry Andric 3777aed8d94eSDimitry Andrictemplate <class _CharT, class _Traits, class _Allocator> 3778aed8d94eSDimitry Andricint 3779aed8d94eSDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, 3780aed8d94eSDimitry Andric size_type __n1, 3781aed8d94eSDimitry Andric const basic_string& __str, 3782aed8d94eSDimitry Andric size_type __pos2, 3783aed8d94eSDimitry Andric size_type __n2) const 3784aed8d94eSDimitry Andric{ 3785aed8d94eSDimitry Andric return compare(__pos1, __n1, __self_view(__str), __pos2, __n2); 3786aed8d94eSDimitry Andric} 3787aed8d94eSDimitry Andric 3788aed8d94eSDimitry Andrictemplate <class _CharT, class _Traits, class _Allocator> 3789aed8d94eSDimitry Andricint 3790aed8d94eSDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::compare(const value_type* __s) const _NOEXCEPT 3791aed8d94eSDimitry Andric{ 3792aed8d94eSDimitry Andric _LIBCPP_ASSERT(__s != nullptr, "string::compare(): received nullptr"); 3793aed8d94eSDimitry Andric return compare(0, npos, __s, traits_type::length(__s)); 3794aed8d94eSDimitry Andric} 3795aed8d94eSDimitry Andric 3796aed8d94eSDimitry Andrictemplate <class _CharT, class _Traits, class _Allocator> 3797aed8d94eSDimitry Andricint 3798aed8d94eSDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, 3799aed8d94eSDimitry Andric size_type __n1, 3800aed8d94eSDimitry Andric const value_type* __s) const 3801aed8d94eSDimitry Andric{ 3802aed8d94eSDimitry Andric _LIBCPP_ASSERT(__s != nullptr, "string::compare(): received nullptr"); 3803aed8d94eSDimitry Andric return compare(__pos1, __n1, __s, traits_type::length(__s)); 3804aed8d94eSDimitry Andric} 3805aed8d94eSDimitry Andric 38067a984708SDavid Chisnall// __invariants 38077a984708SDavid Chisnall 38087a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 3809*b5893f02SDimitry Andricinline 38107a984708SDavid Chisnallbool 38117a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator>::__invariants() const 38127a984708SDavid Chisnall{ 38137a984708SDavid Chisnall if (size() > capacity()) 38147a984708SDavid Chisnall return false; 38157a984708SDavid Chisnall if (capacity() < __min_cap - 1) 38167a984708SDavid Chisnall return false; 38177a984708SDavid Chisnall if (data() == 0) 38187a984708SDavid Chisnall return false; 38197a984708SDavid Chisnall if (data()[size()] != value_type(0)) 38207a984708SDavid Chisnall return false; 38217a984708SDavid Chisnall return true; 38227a984708SDavid Chisnall} 38237a984708SDavid Chisnall 38244ba319b5SDimitry Andric// __clear_and_shrink 38254ba319b5SDimitry Andric 38264ba319b5SDimitry Andrictemplate<class _CharT, class _Traits, class _Allocator> 3827*b5893f02SDimitry Andricinline 38284ba319b5SDimitry Andricvoid 38294ba319b5SDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::__clear_and_shrink() _NOEXCEPT 38304ba319b5SDimitry Andric{ 38314ba319b5SDimitry Andric clear(); 38324ba319b5SDimitry Andric if(__is_long()) 38334ba319b5SDimitry Andric { 38344ba319b5SDimitry Andric __alloc_traits::deallocate(__alloc(), __get_long_pointer(), capacity() + 1); 38354ba319b5SDimitry Andric __set_long_cap(0); 38364ba319b5SDimitry Andric __set_short_size(0); 38374ba319b5SDimitry Andric } 38384ba319b5SDimitry Andric} 38394ba319b5SDimitry Andric 38407a984708SDavid Chisnall// operator== 38417a984708SDavid Chisnall 38427a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 38434f7ab58eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 38447a984708SDavid Chisnallbool 38457a984708SDavid Chisnalloperator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs, 38467a984708SDavid Chisnall const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT 38477a984708SDavid Chisnall{ 38481bf9f7c1SDimitry Andric size_t __lhs_sz = __lhs.size(); 38491bf9f7c1SDimitry Andric return __lhs_sz == __rhs.size() && _Traits::compare(__lhs.data(), 38507a984708SDavid Chisnall __rhs.data(), 38511bf9f7c1SDimitry Andric __lhs_sz) == 0; 38521bf9f7c1SDimitry Andric} 38531bf9f7c1SDimitry Andric 38541bf9f7c1SDimitry Andrictemplate<class _Allocator> 38554f7ab58eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 38561bf9f7c1SDimitry Andricbool 38571bf9f7c1SDimitry Andricoperator==(const basic_string<char, char_traits<char>, _Allocator>& __lhs, 38581bf9f7c1SDimitry Andric const basic_string<char, char_traits<char>, _Allocator>& __rhs) _NOEXCEPT 38591bf9f7c1SDimitry Andric{ 38601bf9f7c1SDimitry Andric size_t __lhs_sz = __lhs.size(); 38611bf9f7c1SDimitry Andric if (__lhs_sz != __rhs.size()) 38621bf9f7c1SDimitry Andric return false; 38631bf9f7c1SDimitry Andric const char* __lp = __lhs.data(); 38641bf9f7c1SDimitry Andric const char* __rp = __rhs.data(); 38651bf9f7c1SDimitry Andric if (__lhs.__is_long()) 38661bf9f7c1SDimitry Andric return char_traits<char>::compare(__lp, __rp, __lhs_sz) == 0; 38671bf9f7c1SDimitry Andric for (; __lhs_sz != 0; --__lhs_sz, ++__lp, ++__rp) 38681bf9f7c1SDimitry Andric if (*__lp != *__rp) 38691bf9f7c1SDimitry Andric return false; 38701bf9f7c1SDimitry Andric return true; 38717a984708SDavid Chisnall} 38727a984708SDavid Chisnall 38737a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 38744f7ab58eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 38757a984708SDavid Chisnallbool 38767a984708SDavid Chisnalloperator==(const _CharT* __lhs, 38777a984708SDavid Chisnall const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT 38787a984708SDavid Chisnall{ 38799729cf09SDimitry Andric typedef basic_string<_CharT, _Traits, _Allocator> _String; 38809729cf09SDimitry Andric _LIBCPP_ASSERT(__lhs != nullptr, "operator==(char*, basic_string): received nullptr"); 38819729cf09SDimitry Andric size_t __lhs_len = _Traits::length(__lhs); 38829729cf09SDimitry Andric if (__lhs_len != __rhs.size()) return false; 38839729cf09SDimitry Andric return __rhs.compare(0, _String::npos, __lhs, __lhs_len) == 0; 38847a984708SDavid Chisnall} 38857a984708SDavid Chisnall 38867a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 38874f7ab58eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 38887a984708SDavid Chisnallbool 38897a984708SDavid Chisnalloperator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs, 38907a984708SDavid Chisnall const _CharT* __rhs) _NOEXCEPT 38917a984708SDavid Chisnall{ 38929729cf09SDimitry Andric typedef basic_string<_CharT, _Traits, _Allocator> _String; 38939729cf09SDimitry Andric _LIBCPP_ASSERT(__rhs != nullptr, "operator==(basic_string, char*): received nullptr"); 38949729cf09SDimitry Andric size_t __rhs_len = _Traits::length(__rhs); 38959729cf09SDimitry Andric if (__rhs_len != __lhs.size()) return false; 38969729cf09SDimitry Andric return __lhs.compare(0, _String::npos, __rhs, __rhs_len) == 0; 38977a984708SDavid Chisnall} 38987a984708SDavid Chisnall 38997a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 39004f7ab58eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 39017a984708SDavid Chisnallbool 39027a984708SDavid Chisnalloperator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs, 39037a984708SDavid Chisnall const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT 39047a984708SDavid Chisnall{ 39057a984708SDavid Chisnall return !(__lhs == __rhs); 39067a984708SDavid Chisnall} 39077a984708SDavid Chisnall 39087a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 39094f7ab58eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 39107a984708SDavid Chisnallbool 39117a984708SDavid Chisnalloperator!=(const _CharT* __lhs, 39127a984708SDavid Chisnall const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT 39137a984708SDavid Chisnall{ 39147a984708SDavid Chisnall return !(__lhs == __rhs); 39157a984708SDavid Chisnall} 39167a984708SDavid Chisnall 39177a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 39184f7ab58eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 39197a984708SDavid Chisnallbool 39207a984708SDavid Chisnalloperator!=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, 39217a984708SDavid Chisnall const _CharT* __rhs) _NOEXCEPT 39227a984708SDavid Chisnall{ 39237a984708SDavid Chisnall return !(__lhs == __rhs); 39247a984708SDavid Chisnall} 39257a984708SDavid Chisnall 39267a984708SDavid Chisnall// operator< 39277a984708SDavid Chisnall 39287a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 39294f7ab58eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 39307a984708SDavid Chisnallbool 39317a984708SDavid Chisnalloperator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs, 39327a984708SDavid Chisnall const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT 39337a984708SDavid Chisnall{ 39347a984708SDavid Chisnall return __lhs.compare(__rhs) < 0; 39357a984708SDavid Chisnall} 39367a984708SDavid Chisnall 39377a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 39384f7ab58eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 39397a984708SDavid Chisnallbool 39407a984708SDavid Chisnalloperator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs, 39417a984708SDavid Chisnall const _CharT* __rhs) _NOEXCEPT 39427a984708SDavid Chisnall{ 39437a984708SDavid Chisnall return __lhs.compare(__rhs) < 0; 39447a984708SDavid Chisnall} 39457a984708SDavid Chisnall 39467a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 39474f7ab58eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 39487a984708SDavid Chisnallbool 39497a984708SDavid Chisnalloperator< (const _CharT* __lhs, 39507a984708SDavid Chisnall const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT 39517a984708SDavid Chisnall{ 39527a984708SDavid Chisnall return __rhs.compare(__lhs) > 0; 39537a984708SDavid Chisnall} 39547a984708SDavid Chisnall 39557a984708SDavid Chisnall// operator> 39567a984708SDavid Chisnall 39577a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 39584f7ab58eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 39597a984708SDavid Chisnallbool 39607a984708SDavid Chisnalloperator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs, 39617a984708SDavid Chisnall const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT 39627a984708SDavid Chisnall{ 39637a984708SDavid Chisnall return __rhs < __lhs; 39647a984708SDavid Chisnall} 39657a984708SDavid Chisnall 39667a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 39674f7ab58eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 39687a984708SDavid Chisnallbool 39697a984708SDavid Chisnalloperator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs, 39707a984708SDavid Chisnall const _CharT* __rhs) _NOEXCEPT 39717a984708SDavid Chisnall{ 39727a984708SDavid Chisnall return __rhs < __lhs; 39737a984708SDavid Chisnall} 39747a984708SDavid Chisnall 39757a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 39764f7ab58eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 39777a984708SDavid Chisnallbool 39787a984708SDavid Chisnalloperator> (const _CharT* __lhs, 39797a984708SDavid Chisnall const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT 39807a984708SDavid Chisnall{ 39817a984708SDavid Chisnall return __rhs < __lhs; 39827a984708SDavid Chisnall} 39837a984708SDavid Chisnall 39847a984708SDavid Chisnall// operator<= 39857a984708SDavid Chisnall 39867a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 39874f7ab58eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 39887a984708SDavid Chisnallbool 39897a984708SDavid Chisnalloperator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, 39907a984708SDavid Chisnall const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT 39917a984708SDavid Chisnall{ 39927a984708SDavid Chisnall return !(__rhs < __lhs); 39937a984708SDavid Chisnall} 39947a984708SDavid Chisnall 39957a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 39964f7ab58eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 39977a984708SDavid Chisnallbool 39987a984708SDavid Chisnalloperator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, 39997a984708SDavid Chisnall const _CharT* __rhs) _NOEXCEPT 40007a984708SDavid Chisnall{ 40017a984708SDavid Chisnall return !(__rhs < __lhs); 40027a984708SDavid Chisnall} 40037a984708SDavid Chisnall 40047a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 40054f7ab58eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 40067a984708SDavid Chisnallbool 40077a984708SDavid Chisnalloperator<=(const _CharT* __lhs, 40087a984708SDavid Chisnall const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT 40097a984708SDavid Chisnall{ 40107a984708SDavid Chisnall return !(__rhs < __lhs); 40117a984708SDavid Chisnall} 40127a984708SDavid Chisnall 40137a984708SDavid Chisnall// operator>= 40147a984708SDavid Chisnall 40157a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 40164f7ab58eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 40177a984708SDavid Chisnallbool 40187a984708SDavid Chisnalloperator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, 40197a984708SDavid Chisnall const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT 40207a984708SDavid Chisnall{ 40217a984708SDavid Chisnall return !(__lhs < __rhs); 40227a984708SDavid Chisnall} 40237a984708SDavid Chisnall 40247a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 40254f7ab58eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 40267a984708SDavid Chisnallbool 40277a984708SDavid Chisnalloperator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, 40287a984708SDavid Chisnall const _CharT* __rhs) _NOEXCEPT 40297a984708SDavid Chisnall{ 40307a984708SDavid Chisnall return !(__lhs < __rhs); 40317a984708SDavid Chisnall} 40327a984708SDavid Chisnall 40337a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 40344f7ab58eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 40357a984708SDavid Chisnallbool 40367a984708SDavid Chisnalloperator>=(const _CharT* __lhs, 40377a984708SDavid Chisnall const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT 40387a984708SDavid Chisnall{ 40397a984708SDavid Chisnall return !(__lhs < __rhs); 40407a984708SDavid Chisnall} 40417a984708SDavid Chisnall 40427a984708SDavid Chisnall// operator + 40437a984708SDavid Chisnall 40447a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 40457a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator> 40467a984708SDavid Chisnalloperator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, 40477a984708SDavid Chisnall const basic_string<_CharT, _Traits, _Allocator>& __rhs) 40487a984708SDavid Chisnall{ 40497a984708SDavid Chisnall basic_string<_CharT, _Traits, _Allocator> __r(__lhs.get_allocator()); 40507a984708SDavid Chisnall typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = __lhs.size(); 40517a984708SDavid Chisnall typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = __rhs.size(); 40527a984708SDavid Chisnall __r.__init(__lhs.data(), __lhs_sz, __lhs_sz + __rhs_sz); 40537a984708SDavid Chisnall __r.append(__rhs.data(), __rhs_sz); 40547a984708SDavid Chisnall return __r; 40557a984708SDavid Chisnall} 40567a984708SDavid Chisnall 40577a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 40587a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator> 40597a984708SDavid Chisnalloperator+(const _CharT* __lhs , const basic_string<_CharT,_Traits,_Allocator>& __rhs) 40607a984708SDavid Chisnall{ 40617a984708SDavid Chisnall basic_string<_CharT, _Traits, _Allocator> __r(__rhs.get_allocator()); 40627a984708SDavid Chisnall typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = _Traits::length(__lhs); 40637a984708SDavid Chisnall typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = __rhs.size(); 40647a984708SDavid Chisnall __r.__init(__lhs, __lhs_sz, __lhs_sz + __rhs_sz); 40657a984708SDavid Chisnall __r.append(__rhs.data(), __rhs_sz); 40667a984708SDavid Chisnall return __r; 40677a984708SDavid Chisnall} 40687a984708SDavid Chisnall 40697a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 40707a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator> 40717a984708SDavid Chisnalloperator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Allocator>& __rhs) 40727a984708SDavid Chisnall{ 40737a984708SDavid Chisnall basic_string<_CharT, _Traits, _Allocator> __r(__rhs.get_allocator()); 40747a984708SDavid Chisnall typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = __rhs.size(); 40757a984708SDavid Chisnall __r.__init(&__lhs, 1, 1 + __rhs_sz); 40767a984708SDavid Chisnall __r.append(__rhs.data(), __rhs_sz); 40777a984708SDavid Chisnall return __r; 40787a984708SDavid Chisnall} 40797a984708SDavid Chisnall 40807a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 4081*b5893f02SDimitry Andricinline 40827a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator> 40837a984708SDavid Chisnalloperator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) 40847a984708SDavid Chisnall{ 40857a984708SDavid Chisnall basic_string<_CharT, _Traits, _Allocator> __r(__lhs.get_allocator()); 40867a984708SDavid Chisnall typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = __lhs.size(); 40877a984708SDavid Chisnall typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = _Traits::length(__rhs); 40887a984708SDavid Chisnall __r.__init(__lhs.data(), __lhs_sz, __lhs_sz + __rhs_sz); 40897a984708SDavid Chisnall __r.append(__rhs, __rhs_sz); 40907a984708SDavid Chisnall return __r; 40917a984708SDavid Chisnall} 40927a984708SDavid Chisnall 40937a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 40947a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator> 40957a984708SDavid Chisnalloperator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, _CharT __rhs) 40967a984708SDavid Chisnall{ 40977a984708SDavid Chisnall basic_string<_CharT, _Traits, _Allocator> __r(__lhs.get_allocator()); 40987a984708SDavid Chisnall typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = __lhs.size(); 40997a984708SDavid Chisnall __r.__init(__lhs.data(), __lhs_sz, __lhs_sz + 1); 41007a984708SDavid Chisnall __r.push_back(__rhs); 41017a984708SDavid Chisnall return __r; 41027a984708SDavid Chisnall} 41037a984708SDavid Chisnall 4104540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 41057a984708SDavid Chisnall 41067a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 41074f7ab58eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 41087a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator> 41097a984708SDavid Chisnalloperator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) 41107a984708SDavid Chisnall{ 41117a984708SDavid Chisnall return _VSTD::move(__lhs.append(__rhs)); 41127a984708SDavid Chisnall} 41137a984708SDavid Chisnall 41147a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 41154f7ab58eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 41167a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator> 41177a984708SDavid Chisnalloperator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs) 41187a984708SDavid Chisnall{ 41197a984708SDavid Chisnall return _VSTD::move(__rhs.insert(0, __lhs)); 41207a984708SDavid Chisnall} 41217a984708SDavid Chisnall 41227a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 41234f7ab58eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 41247a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator> 41257a984708SDavid Chisnalloperator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs) 41267a984708SDavid Chisnall{ 41277a984708SDavid Chisnall return _VSTD::move(__lhs.append(__rhs)); 41287a984708SDavid Chisnall} 41297a984708SDavid Chisnall 41307a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 41314f7ab58eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 41327a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator> 41337a984708SDavid Chisnalloperator+(const _CharT* __lhs , basic_string<_CharT,_Traits,_Allocator>&& __rhs) 41347a984708SDavid Chisnall{ 41357a984708SDavid Chisnall return _VSTD::move(__rhs.insert(0, __lhs)); 41367a984708SDavid Chisnall} 41377a984708SDavid Chisnall 41387a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 41394f7ab58eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 41407a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator> 41417a984708SDavid Chisnalloperator+(_CharT __lhs, basic_string<_CharT,_Traits,_Allocator>&& __rhs) 41427a984708SDavid Chisnall{ 41437a984708SDavid Chisnall __rhs.insert(__rhs.begin(), __lhs); 41447a984708SDavid Chisnall return _VSTD::move(__rhs); 41457a984708SDavid Chisnall} 41467a984708SDavid Chisnall 41477a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 41484f7ab58eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 41497a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator> 41507a984708SDavid Chisnalloperator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const _CharT* __rhs) 41517a984708SDavid Chisnall{ 41527a984708SDavid Chisnall return _VSTD::move(__lhs.append(__rhs)); 41537a984708SDavid Chisnall} 41547a984708SDavid Chisnall 41557a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 41564f7ab58eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 41577a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator> 41587a984708SDavid Chisnalloperator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs) 41597a984708SDavid Chisnall{ 41607a984708SDavid Chisnall __lhs.push_back(__rhs); 41617a984708SDavid Chisnall return _VSTD::move(__lhs); 41627a984708SDavid Chisnall} 41637a984708SDavid Chisnall 4164540d2a8bSDimitry Andric#endif // _LIBCPP_CXX03_LANG 41657a984708SDavid Chisnall 41667a984708SDavid Chisnall// swap 41677a984708SDavid Chisnall 41687a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 41694f7ab58eSDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 41707a984708SDavid Chisnallvoid 41717a984708SDavid Chisnallswap(basic_string<_CharT, _Traits, _Allocator>& __lhs, 41727a984708SDavid Chisnall basic_string<_CharT, _Traits, _Allocator>& __rhs) 41737a984708SDavid Chisnall _NOEXCEPT_(_NOEXCEPT_(__lhs.swap(__rhs))) 41747a984708SDavid Chisnall{ 41757a984708SDavid Chisnall __lhs.swap(__rhs); 41767a984708SDavid Chisnall} 41777a984708SDavid Chisnall 4178*b5893f02SDimitry Andric#ifndef _LIBCPP_NO_HAS_CHAR8_T 4179*b5893f02SDimitry Andrictypedef basic_string<char8_t> u8string; 4180*b5893f02SDimitry Andric#endif 41817a984708SDavid Chisnall 4182*b5893f02SDimitry Andric#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS 41837a984708SDavid Chisnalltypedef basic_string<char16_t> u16string; 41847a984708SDavid Chisnalltypedef basic_string<char32_t> u32string; 41857a984708SDavid Chisnall#endif // _LIBCPP_HAS_NO_UNICODE_CHARS 41867a984708SDavid Chisnall 41874f7ab58eSDimitry Andric_LIBCPP_FUNC_VIS int stoi (const string& __str, size_t* __idx = 0, int __base = 10); 41884f7ab58eSDimitry Andric_LIBCPP_FUNC_VIS long stol (const string& __str, size_t* __idx = 0, int __base = 10); 41894f7ab58eSDimitry Andric_LIBCPP_FUNC_VIS unsigned long stoul (const string& __str, size_t* __idx = 0, int __base = 10); 41904f7ab58eSDimitry Andric_LIBCPP_FUNC_VIS long long stoll (const string& __str, size_t* __idx = 0, int __base = 10); 41914f7ab58eSDimitry Andric_LIBCPP_FUNC_VIS unsigned long long stoull(const string& __str, size_t* __idx = 0, int __base = 10); 41927a984708SDavid Chisnall 41934f7ab58eSDimitry Andric_LIBCPP_FUNC_VIS float stof (const string& __str, size_t* __idx = 0); 41944f7ab58eSDimitry Andric_LIBCPP_FUNC_VIS double stod (const string& __str, size_t* __idx = 0); 41954f7ab58eSDimitry Andric_LIBCPP_FUNC_VIS long double stold(const string& __str, size_t* __idx = 0); 41967a984708SDavid Chisnall 41974f7ab58eSDimitry Andric_LIBCPP_FUNC_VIS string to_string(int __val); 41984f7ab58eSDimitry Andric_LIBCPP_FUNC_VIS string to_string(unsigned __val); 41994f7ab58eSDimitry Andric_LIBCPP_FUNC_VIS string to_string(long __val); 42004f7ab58eSDimitry Andric_LIBCPP_FUNC_VIS string to_string(unsigned long __val); 42014f7ab58eSDimitry Andric_LIBCPP_FUNC_VIS string to_string(long long __val); 42024f7ab58eSDimitry Andric_LIBCPP_FUNC_VIS string to_string(unsigned long long __val); 42034f7ab58eSDimitry Andric_LIBCPP_FUNC_VIS string to_string(float __val); 42044f7ab58eSDimitry Andric_LIBCPP_FUNC_VIS string to_string(double __val); 42054f7ab58eSDimitry Andric_LIBCPP_FUNC_VIS string to_string(long double __val); 42067a984708SDavid Chisnall 42074f7ab58eSDimitry Andric_LIBCPP_FUNC_VIS int stoi (const wstring& __str, size_t* __idx = 0, int __base = 10); 42084f7ab58eSDimitry Andric_LIBCPP_FUNC_VIS long stol (const wstring& __str, size_t* __idx = 0, int __base = 10); 42094f7ab58eSDimitry Andric_LIBCPP_FUNC_VIS unsigned long stoul (const wstring& __str, size_t* __idx = 0, int __base = 10); 42104f7ab58eSDimitry Andric_LIBCPP_FUNC_VIS long long stoll (const wstring& __str, size_t* __idx = 0, int __base = 10); 42114f7ab58eSDimitry Andric_LIBCPP_FUNC_VIS unsigned long long stoull(const wstring& __str, size_t* __idx = 0, int __base = 10); 42127a984708SDavid Chisnall 42134f7ab58eSDimitry Andric_LIBCPP_FUNC_VIS float stof (const wstring& __str, size_t* __idx = 0); 42144f7ab58eSDimitry Andric_LIBCPP_FUNC_VIS double stod (const wstring& __str, size_t* __idx = 0); 42154f7ab58eSDimitry Andric_LIBCPP_FUNC_VIS long double stold(const wstring& __str, size_t* __idx = 0); 42167a984708SDavid Chisnall 42174f7ab58eSDimitry Andric_LIBCPP_FUNC_VIS wstring to_wstring(int __val); 42184f7ab58eSDimitry Andric_LIBCPP_FUNC_VIS wstring to_wstring(unsigned __val); 42194f7ab58eSDimitry Andric_LIBCPP_FUNC_VIS wstring to_wstring(long __val); 42204f7ab58eSDimitry Andric_LIBCPP_FUNC_VIS wstring to_wstring(unsigned long __val); 42214f7ab58eSDimitry Andric_LIBCPP_FUNC_VIS wstring to_wstring(long long __val); 42224f7ab58eSDimitry Andric_LIBCPP_FUNC_VIS wstring to_wstring(unsigned long long __val); 42234f7ab58eSDimitry Andric_LIBCPP_FUNC_VIS wstring to_wstring(float __val); 42244f7ab58eSDimitry Andric_LIBCPP_FUNC_VIS wstring to_wstring(double __val); 42254f7ab58eSDimitry Andric_LIBCPP_FUNC_VIS wstring to_wstring(long double __val); 42267a984708SDavid Chisnall 42277a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 42287a984708SDavid Chisnall const typename basic_string<_CharT, _Traits, _Allocator>::size_type 42297a984708SDavid Chisnall basic_string<_CharT, _Traits, _Allocator>::npos; 42307a984708SDavid Chisnall 42317a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 4232aed8d94eSDimitry Andricstruct _LIBCPP_TEMPLATE_VIS hash<basic_string<_CharT, _Traits, _Allocator> > 42337a984708SDavid Chisnall : public unary_function<basic_string<_CharT, _Traits, _Allocator>, size_t> 42347a984708SDavid Chisnall{ 42357a984708SDavid Chisnall size_t 42367a984708SDavid Chisnall operator()(const basic_string<_CharT, _Traits, _Allocator>& __val) const _NOEXCEPT; 42377a984708SDavid Chisnall}; 42387a984708SDavid Chisnall 42397a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 42407a984708SDavid Chisnallsize_t 42417a984708SDavid Chisnallhash<basic_string<_CharT, _Traits, _Allocator> >::operator()( 42427a984708SDavid Chisnall const basic_string<_CharT, _Traits, _Allocator>& __val) const _NOEXCEPT 42437a984708SDavid Chisnall{ 42447a984708SDavid Chisnall return __do_string_hash(__val.data(), __val.data() + __val.size()); 42457a984708SDavid Chisnall} 42467a984708SDavid Chisnall 42477a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 42487a984708SDavid Chisnallbasic_ostream<_CharT, _Traits>& 42497a984708SDavid Chisnalloperator<<(basic_ostream<_CharT, _Traits>& __os, 42507a984708SDavid Chisnall const basic_string<_CharT, _Traits, _Allocator>& __str); 42517a984708SDavid Chisnall 42527a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 42537a984708SDavid Chisnallbasic_istream<_CharT, _Traits>& 42547a984708SDavid Chisnalloperator>>(basic_istream<_CharT, _Traits>& __is, 42557a984708SDavid Chisnall basic_string<_CharT, _Traits, _Allocator>& __str); 42567a984708SDavid Chisnall 42577a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 42587a984708SDavid Chisnallbasic_istream<_CharT, _Traits>& 42597a984708SDavid Chisnallgetline(basic_istream<_CharT, _Traits>& __is, 42607a984708SDavid Chisnall basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm); 42617a984708SDavid Chisnall 42627a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 42637a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 42647a984708SDavid Chisnallbasic_istream<_CharT, _Traits>& 42657a984708SDavid Chisnallgetline(basic_istream<_CharT, _Traits>& __is, 42667a984708SDavid Chisnall basic_string<_CharT, _Traits, _Allocator>& __str); 42677a984708SDavid Chisnall 4268540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 42697a984708SDavid Chisnall 42707a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 42717a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 42727a984708SDavid Chisnallbasic_istream<_CharT, _Traits>& 42737a984708SDavid Chisnallgetline(basic_istream<_CharT, _Traits>&& __is, 42747a984708SDavid Chisnall basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm); 42757a984708SDavid Chisnall 42767a984708SDavid Chisnalltemplate<class _CharT, class _Traits, class _Allocator> 42777a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 42787a984708SDavid Chisnallbasic_istream<_CharT, _Traits>& 42797a984708SDavid Chisnallgetline(basic_istream<_CharT, _Traits>&& __is, 42807a984708SDavid Chisnall basic_string<_CharT, _Traits, _Allocator>& __str); 42817a984708SDavid Chisnall 4282540d2a8bSDimitry Andric#endif // _LIBCPP_CXX03_LANG 42837a984708SDavid Chisnall 4284*b5893f02SDimitry Andric#if _LIBCPP_STD_VER > 17 4285*b5893f02SDimitry Andrictemplate<class _CharT, class _Traits, class _Allocator, class _Up> 4286*b5893f02SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 4287*b5893f02SDimitry Andricvoid erase(basic_string<_CharT, _Traits, _Allocator>& __str, const _Up& __v) 4288*b5893f02SDimitry Andric{ __str.erase(_VSTD::remove(__str.begin(), __str.end(), __v), __str.end()); } 4289*b5893f02SDimitry Andric 4290*b5893f02SDimitry Andrictemplate<class _CharT, class _Traits, class _Allocator, class _Predicate> 4291*b5893f02SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 4292*b5893f02SDimitry Andricvoid erase_if(basic_string<_CharT, _Traits, _Allocator>& __str, _Predicate __pred) 4293*b5893f02SDimitry Andric{ __str.erase(_VSTD::remove_if(__str.begin(), __str.end(), __pred), __str.end()); } 4294*b5893f02SDimitry Andric#endif 4295*b5893f02SDimitry Andric 42964f7ab58eSDimitry Andric#if _LIBCPP_DEBUG_LEVEL >= 2 42977a984708SDavid Chisnall 42984f7ab58eSDimitry Andrictemplate<class _CharT, class _Traits, class _Allocator> 42994f7ab58eSDimitry Andricbool 43004f7ab58eSDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::__dereferenceable(const const_iterator* __i) const 43014f7ab58eSDimitry Andric{ 43024f7ab58eSDimitry Andric return this->data() <= _VSTD::__to_raw_pointer(__i->base()) && 43034f7ab58eSDimitry Andric _VSTD::__to_raw_pointer(__i->base()) < this->data() + this->size(); 43044f7ab58eSDimitry Andric} 43054f7ab58eSDimitry Andric 43064f7ab58eSDimitry Andrictemplate<class _CharT, class _Traits, class _Allocator> 43074f7ab58eSDimitry Andricbool 43084f7ab58eSDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::__decrementable(const const_iterator* __i) const 43094f7ab58eSDimitry Andric{ 43104f7ab58eSDimitry Andric return this->data() < _VSTD::__to_raw_pointer(__i->base()) && 43114f7ab58eSDimitry Andric _VSTD::__to_raw_pointer(__i->base()) <= this->data() + this->size(); 43124f7ab58eSDimitry Andric} 43134f7ab58eSDimitry Andric 43144f7ab58eSDimitry Andrictemplate<class _CharT, class _Traits, class _Allocator> 43154f7ab58eSDimitry Andricbool 43164f7ab58eSDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::__addable(const const_iterator* __i, ptrdiff_t __n) const 43174f7ab58eSDimitry Andric{ 43184f7ab58eSDimitry Andric const value_type* __p = _VSTD::__to_raw_pointer(__i->base()) + __n; 43194f7ab58eSDimitry Andric return this->data() <= __p && __p <= this->data() + this->size(); 43204f7ab58eSDimitry Andric} 43214f7ab58eSDimitry Andric 43224f7ab58eSDimitry Andrictemplate<class _CharT, class _Traits, class _Allocator> 43234f7ab58eSDimitry Andricbool 43244f7ab58eSDimitry Andricbasic_string<_CharT, _Traits, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __n) const 43254f7ab58eSDimitry Andric{ 43264f7ab58eSDimitry Andric const value_type* __p = _VSTD::__to_raw_pointer(__i->base()) + __n; 43274f7ab58eSDimitry Andric return this->data() <= __p && __p < this->data() + this->size(); 43284f7ab58eSDimitry Andric} 43294f7ab58eSDimitry Andric 43304f7ab58eSDimitry Andric#endif // _LIBCPP_DEBUG_LEVEL >= 2 43314f7ab58eSDimitry Andric 4332a580b014SDimitry Andric_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_string<char>) 4333a580b014SDimitry Andric_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_string<wchar_t>) 4334a580b014SDimitry Andric 43354f7ab58eSDimitry Andric#if _LIBCPP_STD_VER > 11 43364f7ab58eSDimitry Andric// Literal suffixes for basic_string [basic.string.literals] 43374f7ab58eSDimitry Andricinline namespace literals 43384f7ab58eSDimitry Andric{ 43394f7ab58eSDimitry Andric inline namespace string_literals 43404f7ab58eSDimitry Andric { 43414f7ab58eSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 43424f7ab58eSDimitry Andric basic_string<char> operator "" s( const char *__str, size_t __len ) 43434f7ab58eSDimitry Andric { 43444f7ab58eSDimitry Andric return basic_string<char> (__str, __len); 43454f7ab58eSDimitry Andric } 43464f7ab58eSDimitry Andric 43474f7ab58eSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 43484f7ab58eSDimitry Andric basic_string<wchar_t> operator "" s( const wchar_t *__str, size_t __len ) 43494f7ab58eSDimitry Andric { 43504f7ab58eSDimitry Andric return basic_string<wchar_t> (__str, __len); 43514f7ab58eSDimitry Andric } 43524f7ab58eSDimitry Andric 4353*b5893f02SDimitry Andric#ifndef _LIBCPP_NO_HAS_CHAR8_T 4354*b5893f02SDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 4355*b5893f02SDimitry Andric basic_string<char8_t> operator "" s(const char8_t *__str, size_t __len) _NOEXCEPT 4356*b5893f02SDimitry Andric { 4357*b5893f02SDimitry Andric return basic_string<char8_t> (__str, __len); 4358*b5893f02SDimitry Andric } 4359*b5893f02SDimitry Andric#endif 4360*b5893f02SDimitry Andric 43614f7ab58eSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 43624f7ab58eSDimitry Andric basic_string<char16_t> operator "" s( const char16_t *__str, size_t __len ) 43634f7ab58eSDimitry Andric { 43644f7ab58eSDimitry Andric return basic_string<char16_t> (__str, __len); 43654f7ab58eSDimitry Andric } 43664f7ab58eSDimitry Andric 43674f7ab58eSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 43684f7ab58eSDimitry Andric basic_string<char32_t> operator "" s( const char32_t *__str, size_t __len ) 43694f7ab58eSDimitry Andric { 43704f7ab58eSDimitry Andric return basic_string<char32_t> (__str, __len); 43714f7ab58eSDimitry Andric } 43724f7ab58eSDimitry Andric } 43734f7ab58eSDimitry Andric} 43744f7ab58eSDimitry Andric#endif 43754f7ab58eSDimitry Andric 43767a984708SDavid Chisnall_LIBCPP_END_NAMESPACE_STD 43777a984708SDavid Chisnall 4378f9448bf3SDimitry Andric_LIBCPP_POP_MACROS 4379f9448bf3SDimitry Andric 43807a984708SDavid Chisnall#endif // _LIBCPP_STRING 4381