14684ddb6SLionel Sambuc// -*- C++ -*- 24684ddb6SLionel Sambuc//===--------------------------- string -----------------------------------===// 34684ddb6SLionel Sambuc// 44684ddb6SLionel Sambuc// The LLVM Compiler Infrastructure 54684ddb6SLionel Sambuc// 64684ddb6SLionel Sambuc// This file is distributed under the University of Illinois Open Source 74684ddb6SLionel Sambuc// License. See LICENSE.TXT for details. 84684ddb6SLionel Sambuc// 94684ddb6SLionel Sambuc//===----------------------------------------------------------------------===// 104684ddb6SLionel Sambuc 114684ddb6SLionel Sambuc#ifndef _LIBCPP_STRING 124684ddb6SLionel Sambuc#define _LIBCPP_STRING 134684ddb6SLionel Sambuc 144684ddb6SLionel Sambuc/* 154684ddb6SLionel Sambuc string synopsis 164684ddb6SLionel Sambuc 174684ddb6SLionel Sambucnamespace std 184684ddb6SLionel Sambuc{ 194684ddb6SLionel Sambuc 204684ddb6SLionel Sambuctemplate <class stateT> 214684ddb6SLionel Sambucclass fpos 224684ddb6SLionel Sambuc{ 234684ddb6SLionel Sambucprivate: 244684ddb6SLionel Sambuc stateT st; 254684ddb6SLionel Sambucpublic: 264684ddb6SLionel Sambuc fpos(streamoff = streamoff()); 274684ddb6SLionel Sambuc 284684ddb6SLionel Sambuc operator streamoff() const; 294684ddb6SLionel Sambuc 304684ddb6SLionel Sambuc stateT state() const; 314684ddb6SLionel Sambuc void state(stateT); 324684ddb6SLionel Sambuc 334684ddb6SLionel Sambuc fpos& operator+=(streamoff); 344684ddb6SLionel Sambuc fpos operator+ (streamoff) const; 354684ddb6SLionel Sambuc fpos& operator-=(streamoff); 364684ddb6SLionel Sambuc fpos operator- (streamoff) const; 374684ddb6SLionel Sambuc}; 384684ddb6SLionel Sambuc 394684ddb6SLionel Sambuctemplate <class stateT> streamoff operator-(const fpos<stateT>& x, const fpos<stateT>& y); 404684ddb6SLionel Sambuc 414684ddb6SLionel Sambuctemplate <class stateT> bool operator==(const fpos<stateT>& x, const fpos<stateT>& y); 424684ddb6SLionel Sambuctemplate <class stateT> bool operator!=(const fpos<stateT>& x, const fpos<stateT>& y); 434684ddb6SLionel Sambuc 444684ddb6SLionel Sambuctemplate <class charT> 454684ddb6SLionel Sambucstruct char_traits 464684ddb6SLionel Sambuc{ 474684ddb6SLionel Sambuc typedef charT char_type; 484684ddb6SLionel Sambuc typedef ... int_type; 494684ddb6SLionel Sambuc typedef streamoff off_type; 504684ddb6SLionel Sambuc typedef streampos pos_type; 514684ddb6SLionel Sambuc typedef mbstate_t state_type; 524684ddb6SLionel Sambuc 534684ddb6SLionel Sambuc static void assign(char_type& c1, const char_type& c2) noexcept; 544684ddb6SLionel Sambuc static constexpr bool eq(char_type c1, char_type c2) noexcept; 554684ddb6SLionel Sambuc static constexpr bool lt(char_type c1, char_type c2) noexcept; 564684ddb6SLionel Sambuc 574684ddb6SLionel Sambuc static int compare(const char_type* s1, const char_type* s2, size_t n); 584684ddb6SLionel Sambuc static size_t length(const char_type* s); 594684ddb6SLionel Sambuc static const char_type* find(const char_type* s, size_t n, const char_type& a); 604684ddb6SLionel Sambuc static char_type* move(char_type* s1, const char_type* s2, size_t n); 614684ddb6SLionel Sambuc static char_type* copy(char_type* s1, const char_type* s2, size_t n); 624684ddb6SLionel Sambuc static char_type* assign(char_type* s, size_t n, char_type a); 634684ddb6SLionel Sambuc 644684ddb6SLionel Sambuc static constexpr int_type not_eof(int_type c) noexcept; 654684ddb6SLionel Sambuc static constexpr char_type to_char_type(int_type c) noexcept; 664684ddb6SLionel Sambuc static constexpr int_type to_int_type(char_type c) noexcept; 674684ddb6SLionel Sambuc static constexpr bool eq_int_type(int_type c1, int_type c2) noexcept; 684684ddb6SLionel Sambuc static constexpr int_type eof() noexcept; 694684ddb6SLionel Sambuc}; 704684ddb6SLionel Sambuc 714684ddb6SLionel Sambuctemplate <> struct char_traits<char>; 724684ddb6SLionel Sambuctemplate <> struct char_traits<wchar_t>; 734684ddb6SLionel Sambuc 744684ddb6SLionel Sambuctemplate<class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > 754684ddb6SLionel Sambucclass basic_string 764684ddb6SLionel Sambuc{ 774684ddb6SLionel Sambucpublic: 784684ddb6SLionel Sambuc// types: 794684ddb6SLionel Sambuc typedef traits traits_type; 804684ddb6SLionel Sambuc typedef typename traits_type::char_type value_type; 814684ddb6SLionel Sambuc typedef Allocator allocator_type; 824684ddb6SLionel Sambuc typedef typename allocator_type::size_type size_type; 834684ddb6SLionel Sambuc typedef typename allocator_type::difference_type difference_type; 844684ddb6SLionel Sambuc typedef typename allocator_type::reference reference; 854684ddb6SLionel Sambuc typedef typename allocator_type::const_reference const_reference; 864684ddb6SLionel Sambuc typedef typename allocator_type::pointer pointer; 874684ddb6SLionel Sambuc typedef typename allocator_type::const_pointer const_pointer; 884684ddb6SLionel Sambuc typedef implementation-defined iterator; 894684ddb6SLionel Sambuc typedef implementation-defined const_iterator; 904684ddb6SLionel Sambuc typedef std::reverse_iterator<iterator> reverse_iterator; 914684ddb6SLionel Sambuc typedef std::reverse_iterator<const_iterator> const_reverse_iterator; 924684ddb6SLionel Sambuc 934684ddb6SLionel Sambuc static const size_type npos = -1; 944684ddb6SLionel Sambuc 954684ddb6SLionel Sambuc basic_string() 964684ddb6SLionel Sambuc noexcept(is_nothrow_default_constructible<allocator_type>::value); 974684ddb6SLionel Sambuc explicit basic_string(const allocator_type& a); 984684ddb6SLionel Sambuc basic_string(const basic_string& str); 994684ddb6SLionel Sambuc basic_string(basic_string&& str) 1004684ddb6SLionel Sambuc noexcept(is_nothrow_move_constructible<allocator_type>::value); 1014684ddb6SLionel Sambuc basic_string(const basic_string& str, size_type pos, size_type n = npos, 1024684ddb6SLionel Sambuc const allocator_type& a = allocator_type()); 1034684ddb6SLionel Sambuc basic_string(const value_type* s, const allocator_type& a = allocator_type()); 1044684ddb6SLionel Sambuc basic_string(const value_type* s, size_type n, const allocator_type& a = allocator_type()); 1054684ddb6SLionel Sambuc basic_string(size_type n, value_type c, const allocator_type& a = allocator_type()); 1064684ddb6SLionel Sambuc template<class InputIterator> 1074684ddb6SLionel Sambuc basic_string(InputIterator begin, InputIterator end, 1084684ddb6SLionel Sambuc const allocator_type& a = allocator_type()); 1094684ddb6SLionel Sambuc basic_string(initializer_list<value_type>, const Allocator& = Allocator()); 1104684ddb6SLionel Sambuc basic_string(const basic_string&, const Allocator&); 1114684ddb6SLionel Sambuc basic_string(basic_string&&, const Allocator&); 1124684ddb6SLionel Sambuc 1134684ddb6SLionel Sambuc ~basic_string(); 1144684ddb6SLionel Sambuc 1154684ddb6SLionel Sambuc basic_string& operator=(const basic_string& str); 1164684ddb6SLionel Sambuc basic_string& operator=(basic_string&& str) 1174684ddb6SLionel Sambuc noexcept( 118*0a6a1f1dSLionel Sambuc allocator_type::propagate_on_container_move_assignment::value || 119*0a6a1f1dSLionel Sambuc allocator_type::is_always_equal::value ); // C++17 1204684ddb6SLionel Sambuc basic_string& operator=(const value_type* s); 1214684ddb6SLionel Sambuc basic_string& operator=(value_type c); 1224684ddb6SLionel Sambuc basic_string& operator=(initializer_list<value_type>); 1234684ddb6SLionel Sambuc 1244684ddb6SLionel Sambuc iterator begin() noexcept; 1254684ddb6SLionel Sambuc const_iterator begin() const noexcept; 1264684ddb6SLionel Sambuc iterator end() noexcept; 1274684ddb6SLionel Sambuc const_iterator end() const noexcept; 1284684ddb6SLionel Sambuc 1294684ddb6SLionel Sambuc reverse_iterator rbegin() noexcept; 1304684ddb6SLionel Sambuc const_reverse_iterator rbegin() const noexcept; 1314684ddb6SLionel Sambuc reverse_iterator rend() noexcept; 1324684ddb6SLionel Sambuc const_reverse_iterator rend() const noexcept; 1334684ddb6SLionel Sambuc 1344684ddb6SLionel Sambuc const_iterator cbegin() const noexcept; 1354684ddb6SLionel Sambuc const_iterator cend() const noexcept; 1364684ddb6SLionel Sambuc const_reverse_iterator crbegin() const noexcept; 1374684ddb6SLionel Sambuc const_reverse_iterator crend() const noexcept; 1384684ddb6SLionel Sambuc 1394684ddb6SLionel Sambuc size_type size() const noexcept; 1404684ddb6SLionel Sambuc size_type length() const noexcept; 1414684ddb6SLionel Sambuc size_type max_size() const noexcept; 1424684ddb6SLionel Sambuc size_type capacity() const noexcept; 1434684ddb6SLionel Sambuc 1444684ddb6SLionel Sambuc void resize(size_type n, value_type c); 1454684ddb6SLionel Sambuc void resize(size_type n); 1464684ddb6SLionel Sambuc 1474684ddb6SLionel Sambuc void reserve(size_type res_arg = 0); 1484684ddb6SLionel Sambuc void shrink_to_fit(); 1494684ddb6SLionel Sambuc void clear() noexcept; 1504684ddb6SLionel Sambuc bool empty() const noexcept; 1514684ddb6SLionel Sambuc 1524684ddb6SLionel Sambuc const_reference operator[](size_type pos) const; 1534684ddb6SLionel Sambuc reference operator[](size_type pos); 1544684ddb6SLionel Sambuc 1554684ddb6SLionel Sambuc const_reference at(size_type n) const; 1564684ddb6SLionel Sambuc reference at(size_type n); 1574684ddb6SLionel Sambuc 1584684ddb6SLionel Sambuc basic_string& operator+=(const basic_string& str); 1594684ddb6SLionel Sambuc basic_string& operator+=(const value_type* s); 1604684ddb6SLionel Sambuc basic_string& operator+=(value_type c); 1614684ddb6SLionel Sambuc basic_string& operator+=(initializer_list<value_type>); 1624684ddb6SLionel Sambuc 1634684ddb6SLionel Sambuc basic_string& append(const basic_string& str); 164*0a6a1f1dSLionel Sambuc basic_string& append(const basic_string& str, size_type pos, size_type n=npos); //C++14 1654684ddb6SLionel Sambuc basic_string& append(const value_type* s, size_type n); 1664684ddb6SLionel Sambuc basic_string& append(const value_type* s); 1674684ddb6SLionel Sambuc basic_string& append(size_type n, value_type c); 1684684ddb6SLionel Sambuc template<class InputIterator> 1694684ddb6SLionel Sambuc basic_string& append(InputIterator first, InputIterator last); 1704684ddb6SLionel Sambuc basic_string& append(initializer_list<value_type>); 1714684ddb6SLionel Sambuc 1724684ddb6SLionel Sambuc void push_back(value_type c); 1734684ddb6SLionel Sambuc void pop_back(); 1744684ddb6SLionel Sambuc reference front(); 1754684ddb6SLionel Sambuc const_reference front() const; 1764684ddb6SLionel Sambuc reference back(); 1774684ddb6SLionel Sambuc const_reference back() const; 1784684ddb6SLionel Sambuc 1794684ddb6SLionel Sambuc basic_string& assign(const basic_string& str); 1804684ddb6SLionel Sambuc basic_string& assign(basic_string&& str); 181*0a6a1f1dSLionel Sambuc basic_string& assign(const basic_string& str, size_type pos, size_type n=npos); // C++14 1824684ddb6SLionel Sambuc basic_string& assign(const value_type* s, size_type n); 1834684ddb6SLionel Sambuc basic_string& assign(const value_type* s); 1844684ddb6SLionel Sambuc basic_string& assign(size_type n, value_type c); 1854684ddb6SLionel Sambuc template<class InputIterator> 1864684ddb6SLionel Sambuc basic_string& assign(InputIterator first, InputIterator last); 1874684ddb6SLionel Sambuc basic_string& assign(initializer_list<value_type>); 1884684ddb6SLionel Sambuc 1894684ddb6SLionel Sambuc basic_string& insert(size_type pos1, const basic_string& str); 1904684ddb6SLionel Sambuc basic_string& insert(size_type pos1, const basic_string& str, 1914684ddb6SLionel Sambuc size_type pos2, size_type n); 192*0a6a1f1dSLionel Sambuc basic_string& insert(size_type pos, const value_type* s, size_type n=npos); //C++14 1934684ddb6SLionel Sambuc basic_string& insert(size_type pos, const value_type* s); 1944684ddb6SLionel Sambuc basic_string& insert(size_type pos, size_type n, value_type c); 1954684ddb6SLionel Sambuc iterator insert(const_iterator p, value_type c); 1964684ddb6SLionel Sambuc iterator insert(const_iterator p, size_type n, value_type c); 1974684ddb6SLionel Sambuc template<class InputIterator> 1984684ddb6SLionel Sambuc iterator insert(const_iterator p, InputIterator first, InputIterator last); 1994684ddb6SLionel Sambuc iterator insert(const_iterator p, initializer_list<value_type>); 2004684ddb6SLionel Sambuc 2014684ddb6SLionel Sambuc basic_string& erase(size_type pos = 0, size_type n = npos); 2024684ddb6SLionel Sambuc iterator erase(const_iterator position); 2034684ddb6SLionel Sambuc iterator erase(const_iterator first, const_iterator last); 2044684ddb6SLionel Sambuc 2054684ddb6SLionel Sambuc basic_string& replace(size_type pos1, size_type n1, const basic_string& str); 2064684ddb6SLionel Sambuc basic_string& replace(size_type pos1, size_type n1, const basic_string& str, 207*0a6a1f1dSLionel Sambuc size_type pos2, size_type n2=npos); // C++14 2084684ddb6SLionel Sambuc basic_string& replace(size_type pos, size_type n1, const value_type* s, size_type n2); 2094684ddb6SLionel Sambuc basic_string& replace(size_type pos, size_type n1, const value_type* s); 2104684ddb6SLionel Sambuc basic_string& replace(size_type pos, size_type n1, size_type n2, value_type c); 2114684ddb6SLionel Sambuc basic_string& replace(const_iterator i1, const_iterator i2, const basic_string& str); 2124684ddb6SLionel Sambuc basic_string& replace(const_iterator i1, const_iterator i2, const value_type* s, size_type n); 2134684ddb6SLionel Sambuc basic_string& replace(const_iterator i1, const_iterator i2, const value_type* s); 2144684ddb6SLionel Sambuc basic_string& replace(const_iterator i1, const_iterator i2, size_type n, value_type c); 2154684ddb6SLionel Sambuc template<class InputIterator> 2164684ddb6SLionel Sambuc basic_string& replace(const_iterator i1, const_iterator i2, InputIterator j1, InputIterator j2); 2174684ddb6SLionel Sambuc basic_string& replace(const_iterator i1, const_iterator i2, initializer_list<value_type>); 2184684ddb6SLionel Sambuc 2194684ddb6SLionel Sambuc size_type copy(value_type* s, size_type n, size_type pos = 0) const; 2204684ddb6SLionel Sambuc basic_string substr(size_type pos = 0, size_type n = npos) const; 2214684ddb6SLionel Sambuc 2224684ddb6SLionel Sambuc void swap(basic_string& str) 223*0a6a1f1dSLionel Sambuc noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value || 224*0a6a1f1dSLionel Sambuc allocator_traits<allocator_type>::is_always_equal::value); // C++17 2254684ddb6SLionel Sambuc 2264684ddb6SLionel Sambuc const value_type* c_str() const noexcept; 2274684ddb6SLionel Sambuc const value_type* data() const noexcept; 2284684ddb6SLionel Sambuc 2294684ddb6SLionel Sambuc allocator_type get_allocator() const noexcept; 2304684ddb6SLionel Sambuc 2314684ddb6SLionel Sambuc size_type find(const basic_string& str, size_type pos = 0) const noexcept; 2324684ddb6SLionel Sambuc size_type find(const value_type* s, size_type pos, size_type n) const noexcept; 2334684ddb6SLionel Sambuc size_type find(const value_type* s, size_type pos = 0) const noexcept; 2344684ddb6SLionel Sambuc size_type find(value_type c, size_type pos = 0) const noexcept; 2354684ddb6SLionel Sambuc 2364684ddb6SLionel Sambuc size_type rfind(const basic_string& str, size_type pos = npos) const noexcept; 2374684ddb6SLionel Sambuc size_type rfind(const value_type* s, size_type pos, size_type n) const noexcept; 2384684ddb6SLionel Sambuc size_type rfind(const value_type* s, size_type pos = npos) const noexcept; 2394684ddb6SLionel Sambuc size_type rfind(value_type c, size_type pos = npos) const noexcept; 2404684ddb6SLionel Sambuc 2414684ddb6SLionel Sambuc size_type find_first_of(const basic_string& str, size_type pos = 0) const noexcept; 2424684ddb6SLionel Sambuc size_type find_first_of(const value_type* s, size_type pos, size_type n) const noexcept; 2434684ddb6SLionel Sambuc size_type find_first_of(const value_type* s, size_type pos = 0) const noexcept; 2444684ddb6SLionel Sambuc size_type find_first_of(value_type c, size_type pos = 0) const noexcept; 2454684ddb6SLionel Sambuc 2464684ddb6SLionel Sambuc size_type find_last_of(const basic_string& str, size_type pos = npos) const noexcept; 2474684ddb6SLionel Sambuc size_type find_last_of(const value_type* s, size_type pos, size_type n) const noexcept; 2484684ddb6SLionel Sambuc size_type find_last_of(const value_type* s, size_type pos = npos) const noexcept; 2494684ddb6SLionel Sambuc size_type find_last_of(value_type c, size_type pos = npos) const noexcept; 2504684ddb6SLionel Sambuc 2514684ddb6SLionel Sambuc size_type find_first_not_of(const basic_string& str, size_type pos = 0) const noexcept; 2524684ddb6SLionel Sambuc size_type find_first_not_of(const value_type* s, size_type pos, size_type n) const noexcept; 2534684ddb6SLionel Sambuc size_type find_first_not_of(const value_type* s, size_type pos = 0) const noexcept; 2544684ddb6SLionel Sambuc size_type find_first_not_of(value_type c, size_type pos = 0) const noexcept; 2554684ddb6SLionel Sambuc 2564684ddb6SLionel Sambuc size_type find_last_not_of(const basic_string& str, size_type pos = npos) const noexcept; 2574684ddb6SLionel Sambuc size_type find_last_not_of(const value_type* s, size_type pos, size_type n) const noexcept; 2584684ddb6SLionel Sambuc size_type find_last_not_of(const value_type* s, size_type pos = npos) const noexcept; 2594684ddb6SLionel Sambuc size_type find_last_not_of(value_type c, size_type pos = npos) const noexcept; 2604684ddb6SLionel Sambuc 2614684ddb6SLionel Sambuc int compare(const basic_string& str) const noexcept; 2624684ddb6SLionel Sambuc int compare(size_type pos1, size_type n1, const basic_string& str) const; 2634684ddb6SLionel Sambuc int compare(size_type pos1, size_type n1, const basic_string& str, 264*0a6a1f1dSLionel Sambuc size_type pos2, size_type n2=npos) const; // C++14 2654684ddb6SLionel Sambuc int compare(const value_type* s) const noexcept; 2664684ddb6SLionel Sambuc int compare(size_type pos1, size_type n1, const value_type* s) const; 2674684ddb6SLionel Sambuc int compare(size_type pos1, size_type n1, const value_type* s, size_type n2) const; 2684684ddb6SLionel Sambuc 2694684ddb6SLionel Sambuc bool __invariants() const; 2704684ddb6SLionel Sambuc}; 2714684ddb6SLionel Sambuc 2724684ddb6SLionel Sambuctemplate<class charT, class traits, class Allocator> 2734684ddb6SLionel Sambucbasic_string<charT, traits, Allocator> 2744684ddb6SLionel Sambucoperator+(const basic_string<charT, traits, Allocator>& lhs, 2754684ddb6SLionel Sambuc const basic_string<charT, traits, Allocator>& rhs); 2764684ddb6SLionel Sambuc 2774684ddb6SLionel Sambuctemplate<class charT, class traits, class Allocator> 2784684ddb6SLionel Sambucbasic_string<charT, traits, Allocator> 2794684ddb6SLionel Sambucoperator+(const charT* lhs , const basic_string<charT,traits,Allocator>&rhs); 2804684ddb6SLionel Sambuc 2814684ddb6SLionel Sambuctemplate<class charT, class traits, class Allocator> 2824684ddb6SLionel Sambucbasic_string<charT, traits, Allocator> 2834684ddb6SLionel Sambucoperator+(charT lhs, const basic_string<charT,traits,Allocator>& rhs); 2844684ddb6SLionel Sambuc 2854684ddb6SLionel Sambuctemplate<class charT, class traits, class Allocator> 2864684ddb6SLionel Sambucbasic_string<charT, traits, Allocator> 2874684ddb6SLionel Sambucoperator+(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs); 2884684ddb6SLionel Sambuc 2894684ddb6SLionel Sambuctemplate<class charT, class traits, class Allocator> 2904684ddb6SLionel Sambucbasic_string<charT, traits, Allocator> 2914684ddb6SLionel Sambucoperator+(const basic_string<charT, traits, Allocator>& lhs, charT rhs); 2924684ddb6SLionel Sambuc 2934684ddb6SLionel Sambuctemplate<class charT, class traits, class Allocator> 2944684ddb6SLionel Sambucbool operator==(const basic_string<charT, traits, Allocator>& lhs, 2954684ddb6SLionel Sambuc const basic_string<charT, traits, Allocator>& rhs) noexcept; 2964684ddb6SLionel Sambuc 2974684ddb6SLionel Sambuctemplate<class charT, class traits, class Allocator> 2984684ddb6SLionel Sambucbool operator==(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; 2994684ddb6SLionel Sambuc 3004684ddb6SLionel Sambuctemplate<class charT, class traits, class Allocator> 3014684ddb6SLionel Sambucbool operator==(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs) noexcept; 3024684ddb6SLionel Sambuc 3034684ddb6SLionel Sambuctemplate<class charT, class traits, class Allocator> 3044684ddb6SLionel Sambucbool operator!=(const basic_string<charT,traits,Allocator>& lhs, 3054684ddb6SLionel Sambuc const basic_string<charT, traits, Allocator>& rhs) noexcept; 3064684ddb6SLionel Sambuc 3074684ddb6SLionel Sambuctemplate<class charT, class traits, class Allocator> 3084684ddb6SLionel Sambucbool operator!=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; 3094684ddb6SLionel Sambuc 3104684ddb6SLionel Sambuctemplate<class charT, class traits, class Allocator> 3114684ddb6SLionel Sambucbool operator!=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; 3124684ddb6SLionel Sambuc 3134684ddb6SLionel Sambuctemplate<class charT, class traits, class Allocator> 3144684ddb6SLionel Sambucbool operator< (const basic_string<charT, traits, Allocator>& lhs, 3154684ddb6SLionel Sambuc const basic_string<charT, traits, Allocator>& rhs) noexcept; 3164684ddb6SLionel Sambuc 3174684ddb6SLionel Sambuctemplate<class charT, class traits, class Allocator> 3184684ddb6SLionel Sambucbool operator< (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; 3194684ddb6SLionel Sambuc 3204684ddb6SLionel Sambuctemplate<class charT, class traits, class Allocator> 3214684ddb6SLionel Sambucbool operator< (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; 3224684ddb6SLionel Sambuc 3234684ddb6SLionel Sambuctemplate<class charT, class traits, class Allocator> 3244684ddb6SLionel Sambucbool operator> (const basic_string<charT, traits, Allocator>& lhs, 3254684ddb6SLionel Sambuc const basic_string<charT, traits, Allocator>& rhs) noexcept; 3264684ddb6SLionel Sambuc 3274684ddb6SLionel Sambuctemplate<class charT, class traits, class Allocator> 3284684ddb6SLionel Sambucbool operator> (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; 3294684ddb6SLionel Sambuc 3304684ddb6SLionel Sambuctemplate<class charT, class traits, class Allocator> 3314684ddb6SLionel Sambucbool operator> (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; 3324684ddb6SLionel Sambuc 3334684ddb6SLionel Sambuctemplate<class charT, class traits, class Allocator> 3344684ddb6SLionel Sambucbool operator<=(const basic_string<charT, traits, Allocator>& lhs, 3354684ddb6SLionel Sambuc const basic_string<charT, traits, Allocator>& rhs) noexcept; 3364684ddb6SLionel Sambuc 3374684ddb6SLionel Sambuctemplate<class charT, class traits, class Allocator> 3384684ddb6SLionel Sambucbool operator<=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; 3394684ddb6SLionel Sambuc 3404684ddb6SLionel Sambuctemplate<class charT, class traits, class Allocator> 3414684ddb6SLionel Sambucbool operator<=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; 3424684ddb6SLionel Sambuc 3434684ddb6SLionel Sambuctemplate<class charT, class traits, class Allocator> 3444684ddb6SLionel Sambucbool operator>=(const basic_string<charT, traits, Allocator>& lhs, 3454684ddb6SLionel Sambuc const basic_string<charT, traits, Allocator>& rhs) noexcept; 3464684ddb6SLionel Sambuc 3474684ddb6SLionel Sambuctemplate<class charT, class traits, class Allocator> 3484684ddb6SLionel Sambucbool operator>=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; 3494684ddb6SLionel Sambuc 3504684ddb6SLionel Sambuctemplate<class charT, class traits, class Allocator> 3514684ddb6SLionel Sambucbool operator>=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; 3524684ddb6SLionel Sambuc 3534684ddb6SLionel Sambuctemplate<class charT, class traits, class Allocator> 3544684ddb6SLionel Sambucvoid swap(basic_string<charT, traits, Allocator>& lhs, 3554684ddb6SLionel Sambuc basic_string<charT, traits, Allocator>& rhs) 3564684ddb6SLionel Sambuc noexcept(noexcept(lhs.swap(rhs))); 3574684ddb6SLionel Sambuc 3584684ddb6SLionel Sambuctemplate<class charT, class traits, class Allocator> 3594684ddb6SLionel Sambucbasic_istream<charT, traits>& 3604684ddb6SLionel Sambucoperator>>(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str); 3614684ddb6SLionel Sambuc 3624684ddb6SLionel Sambuctemplate<class charT, class traits, class Allocator> 3634684ddb6SLionel Sambucbasic_ostream<charT, traits>& 3644684ddb6SLionel Sambucoperator<<(basic_ostream<charT, traits>& os, const basic_string<charT, traits, Allocator>& str); 3654684ddb6SLionel Sambuc 3664684ddb6SLionel Sambuctemplate<class charT, class traits, class Allocator> 3674684ddb6SLionel Sambucbasic_istream<charT, traits>& 3684684ddb6SLionel Sambucgetline(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str, 3694684ddb6SLionel Sambuc charT delim); 3704684ddb6SLionel Sambuc 3714684ddb6SLionel Sambuctemplate<class charT, class traits, class Allocator> 3724684ddb6SLionel Sambucbasic_istream<charT, traits>& 3734684ddb6SLionel Sambucgetline(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str); 3744684ddb6SLionel Sambuc 3754684ddb6SLionel Sambuctypedef basic_string<char> string; 3764684ddb6SLionel Sambuctypedef basic_string<wchar_t> wstring; 3774684ddb6SLionel Sambuctypedef basic_string<char16_t> u16string; 3784684ddb6SLionel Sambuctypedef basic_string<char32_t> u32string; 3794684ddb6SLionel Sambuc 3804684ddb6SLionel Sambucint stoi (const string& str, size_t* idx = 0, int base = 10); 3814684ddb6SLionel Sambuclong stol (const string& str, size_t* idx = 0, int base = 10); 3824684ddb6SLionel Sambucunsigned long stoul (const string& str, size_t* idx = 0, int base = 10); 3834684ddb6SLionel Sambuclong long stoll (const string& str, size_t* idx = 0, int base = 10); 3844684ddb6SLionel Sambucunsigned long long stoull(const string& str, size_t* idx = 0, int base = 10); 3854684ddb6SLionel Sambuc 3864684ddb6SLionel Sambucfloat stof (const string& str, size_t* idx = 0); 3874684ddb6SLionel Sambucdouble stod (const string& str, size_t* idx = 0); 3884684ddb6SLionel Sambuclong double stold(const string& str, size_t* idx = 0); 3894684ddb6SLionel Sambuc 3904684ddb6SLionel Sambucstring to_string(int val); 3914684ddb6SLionel Sambucstring to_string(unsigned val); 3924684ddb6SLionel Sambucstring to_string(long val); 3934684ddb6SLionel Sambucstring to_string(unsigned long val); 3944684ddb6SLionel Sambucstring to_string(long long val); 3954684ddb6SLionel Sambucstring to_string(unsigned long long val); 3964684ddb6SLionel Sambucstring to_string(float val); 3974684ddb6SLionel Sambucstring to_string(double val); 3984684ddb6SLionel Sambucstring to_string(long double val); 3994684ddb6SLionel Sambuc 4004684ddb6SLionel Sambucint stoi (const wstring& str, size_t* idx = 0, int base = 10); 4014684ddb6SLionel Sambuclong stol (const wstring& str, size_t* idx = 0, int base = 10); 4024684ddb6SLionel Sambucunsigned long stoul (const wstring& str, size_t* idx = 0, int base = 10); 4034684ddb6SLionel Sambuclong long stoll (const wstring& str, size_t* idx = 0, int base = 10); 4044684ddb6SLionel Sambucunsigned long long stoull(const wstring& str, size_t* idx = 0, int base = 10); 4054684ddb6SLionel Sambuc 4064684ddb6SLionel Sambucfloat stof (const wstring& str, size_t* idx = 0); 4074684ddb6SLionel Sambucdouble stod (const wstring& str, size_t* idx = 0); 4084684ddb6SLionel Sambuclong double stold(const wstring& str, size_t* idx = 0); 4094684ddb6SLionel Sambuc 4104684ddb6SLionel Sambucwstring to_wstring(int val); 4114684ddb6SLionel Sambucwstring to_wstring(unsigned val); 4124684ddb6SLionel Sambucwstring to_wstring(long val); 4134684ddb6SLionel Sambucwstring to_wstring(unsigned long val); 4144684ddb6SLionel Sambucwstring to_wstring(long long val); 4154684ddb6SLionel Sambucwstring to_wstring(unsigned long long val); 4164684ddb6SLionel Sambucwstring to_wstring(float val); 4174684ddb6SLionel Sambucwstring to_wstring(double val); 4184684ddb6SLionel Sambucwstring to_wstring(long double val); 4194684ddb6SLionel Sambuc 4204684ddb6SLionel Sambuctemplate <> struct hash<string>; 4214684ddb6SLionel Sambuctemplate <> struct hash<u16string>; 4224684ddb6SLionel Sambuctemplate <> struct hash<u32string>; 4234684ddb6SLionel Sambuctemplate <> struct hash<wstring>; 4244684ddb6SLionel Sambuc 4254684ddb6SLionel Sambucbasic_string<char> operator "" s( const char *str, size_t len ); // C++14 4264684ddb6SLionel Sambucbasic_string<wchar_t> operator "" s( const wchar_t *str, size_t len ); // C++14 4274684ddb6SLionel Sambucbasic_string<char16_t> operator "" s( const char16_t *str, size_t len ); // C++14 4284684ddb6SLionel Sambucbasic_string<char32_t> operator "" s( const char32_t *str, size_t len ); // C++14 4294684ddb6SLionel Sambuc 4304684ddb6SLionel Sambuc} // std 4314684ddb6SLionel Sambuc 4324684ddb6SLionel Sambuc*/ 4334684ddb6SLionel Sambuc 4344684ddb6SLionel Sambuc#include <__config> 4354684ddb6SLionel Sambuc#include <iosfwd> 4364684ddb6SLionel Sambuc#include <cstring> 4374684ddb6SLionel Sambuc#include <cstdio> // For EOF. 4384684ddb6SLionel Sambuc#include <cwchar> 4394684ddb6SLionel Sambuc#include <algorithm> 4404684ddb6SLionel Sambuc#include <iterator> 4414684ddb6SLionel Sambuc#include <utility> 4424684ddb6SLionel Sambuc#include <memory> 4434684ddb6SLionel Sambuc#include <stdexcept> 4444684ddb6SLionel Sambuc#include <type_traits> 4454684ddb6SLionel Sambuc#include <initializer_list> 4464684ddb6SLionel Sambuc#include <__functional_base> 4474684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS 4484684ddb6SLionel Sambuc#include <cstdint> 4494684ddb6SLionel Sambuc#endif 4504684ddb6SLionel Sambuc#if defined(_LIBCPP_NO_EXCEPTIONS) 4514684ddb6SLionel Sambuc#include <cassert> 4524684ddb6SLionel Sambuc#endif 4534684ddb6SLionel Sambuc 4544684ddb6SLionel Sambuc#include <__undef_min_max> 4554684ddb6SLionel Sambuc 456*0a6a1f1dSLionel Sambuc#include <__debug> 457*0a6a1f1dSLionel Sambuc 4584684ddb6SLionel Sambuc#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 4594684ddb6SLionel Sambuc#pragma GCC system_header 4604684ddb6SLionel Sambuc#endif 4614684ddb6SLionel Sambuc 4624684ddb6SLionel Sambuc_LIBCPP_BEGIN_NAMESPACE_STD 4634684ddb6SLionel Sambuc 4644684ddb6SLionel Sambuc// fpos 4654684ddb6SLionel Sambuc 4664684ddb6SLionel Sambuctemplate <class _StateT> 4674684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY fpos 4684684ddb6SLionel Sambuc{ 4694684ddb6SLionel Sambucprivate: 4704684ddb6SLionel Sambuc _StateT __st_; 4714684ddb6SLionel Sambuc streamoff __off_; 4724684ddb6SLionel Sambucpublic: 4734684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY fpos(streamoff __off = streamoff()) : __st_(), __off_(__off) {} 4744684ddb6SLionel Sambuc 4754684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY operator streamoff() const {return __off_;} 4764684ddb6SLionel Sambuc 4774684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY _StateT state() const {return __st_;} 4784684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY void state(_StateT __st) {__st_ = __st;} 4794684ddb6SLionel Sambuc 4804684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY fpos& operator+=(streamoff __off) {__off_ += __off; return *this;} 4814684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY fpos operator+ (streamoff __off) const {fpos __t(*this); __t += __off; return __t;} 4824684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY fpos& operator-=(streamoff __off) {__off_ -= __off; return *this;} 4834684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY fpos operator- (streamoff __off) const {fpos __t(*this); __t -= __off; return __t;} 4844684ddb6SLionel Sambuc}; 4854684ddb6SLionel Sambuc 4864684ddb6SLionel Sambuctemplate <class _StateT> 4874684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 4884684ddb6SLionel Sambucstreamoff operator-(const fpos<_StateT>& __x, const fpos<_StateT>& __y) 4894684ddb6SLionel Sambuc {return streamoff(__x) - streamoff(__y);} 4904684ddb6SLionel Sambuc 4914684ddb6SLionel Sambuctemplate <class _StateT> 4924684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 4934684ddb6SLionel Sambucbool operator==(const fpos<_StateT>& __x, const fpos<_StateT>& __y) 4944684ddb6SLionel Sambuc {return streamoff(__x) == streamoff(__y);} 4954684ddb6SLionel Sambuc 4964684ddb6SLionel Sambuctemplate <class _StateT> 4974684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 4984684ddb6SLionel Sambucbool operator!=(const fpos<_StateT>& __x, const fpos<_StateT>& __y) 4994684ddb6SLionel Sambuc {return streamoff(__x) != streamoff(__y);} 5004684ddb6SLionel Sambuc 5014684ddb6SLionel Sambuc// char_traits 5024684ddb6SLionel Sambuc 5034684ddb6SLionel Sambuctemplate <class _CharT> 5044684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY char_traits 5054684ddb6SLionel Sambuc{ 5064684ddb6SLionel Sambuc typedef _CharT char_type; 5074684ddb6SLionel Sambuc typedef int int_type; 5084684ddb6SLionel Sambuc typedef streamoff off_type; 5094684ddb6SLionel Sambuc typedef streampos pos_type; 5104684ddb6SLionel Sambuc typedef mbstate_t state_type; 5114684ddb6SLionel Sambuc 512*0a6a1f1dSLionel Sambuc static inline void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT 5134684ddb6SLionel Sambuc {__c1 = __c2;} 514*0a6a1f1dSLionel Sambuc static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT 5154684ddb6SLionel Sambuc {return __c1 == __c2;} 516*0a6a1f1dSLionel Sambuc static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT 5174684ddb6SLionel Sambuc {return __c1 < __c2;} 5184684ddb6SLionel Sambuc 5194684ddb6SLionel Sambuc static int compare(const char_type* __s1, const char_type* __s2, size_t __n); 5204684ddb6SLionel Sambuc static size_t length(const char_type* __s); 5214684ddb6SLionel Sambuc static const char_type* find(const char_type* __s, size_t __n, const char_type& __a); 5224684ddb6SLionel Sambuc static char_type* move(char_type* __s1, const char_type* __s2, size_t __n); 5234684ddb6SLionel Sambuc static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n); 5244684ddb6SLionel Sambuc static char_type* assign(char_type* __s, size_t __n, char_type __a); 5254684ddb6SLionel Sambuc 526*0a6a1f1dSLionel Sambuc static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT 5274684ddb6SLionel Sambuc {return eq_int_type(__c, eof()) ? ~eof() : __c;} 528*0a6a1f1dSLionel Sambuc static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT 5294684ddb6SLionel Sambuc {return char_type(__c);} 530*0a6a1f1dSLionel Sambuc static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT 5314684ddb6SLionel Sambuc {return int_type(__c);} 532*0a6a1f1dSLionel Sambuc static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT 5334684ddb6SLionel Sambuc {return __c1 == __c2;} 534*0a6a1f1dSLionel Sambuc static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT 5354684ddb6SLionel Sambuc {return int_type(EOF);} 5364684ddb6SLionel Sambuc}; 5374684ddb6SLionel Sambuc 5384684ddb6SLionel Sambuctemplate <class _CharT> 5394684ddb6SLionel Sambucint 5404684ddb6SLionel Sambucchar_traits<_CharT>::compare(const char_type* __s1, const char_type* __s2, size_t __n) 5414684ddb6SLionel Sambuc{ 5424684ddb6SLionel Sambuc for (; __n; --__n, ++__s1, ++__s2) 5434684ddb6SLionel Sambuc { 5444684ddb6SLionel Sambuc if (lt(*__s1, *__s2)) 5454684ddb6SLionel Sambuc return -1; 5464684ddb6SLionel Sambuc if (lt(*__s2, *__s1)) 5474684ddb6SLionel Sambuc return 1; 5484684ddb6SLionel Sambuc } 5494684ddb6SLionel Sambuc return 0; 5504684ddb6SLionel Sambuc} 5514684ddb6SLionel Sambuc 5524684ddb6SLionel Sambuctemplate <class _CharT> 5534684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 5544684ddb6SLionel Sambucsize_t 5554684ddb6SLionel Sambucchar_traits<_CharT>::length(const char_type* __s) 5564684ddb6SLionel Sambuc{ 5574684ddb6SLionel Sambuc size_t __len = 0; 5584684ddb6SLionel Sambuc for (; !eq(*__s, char_type(0)); ++__s) 5594684ddb6SLionel Sambuc ++__len; 5604684ddb6SLionel Sambuc return __len; 5614684ddb6SLionel Sambuc} 5624684ddb6SLionel Sambuc 5634684ddb6SLionel Sambuctemplate <class _CharT> 5644684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 5654684ddb6SLionel Sambucconst _CharT* 5664684ddb6SLionel Sambucchar_traits<_CharT>::find(const char_type* __s, size_t __n, const char_type& __a) 5674684ddb6SLionel Sambuc{ 5684684ddb6SLionel Sambuc for (; __n; --__n) 5694684ddb6SLionel Sambuc { 5704684ddb6SLionel Sambuc if (eq(*__s, __a)) 5714684ddb6SLionel Sambuc return __s; 5724684ddb6SLionel Sambuc ++__s; 5734684ddb6SLionel Sambuc } 5744684ddb6SLionel Sambuc return 0; 5754684ddb6SLionel Sambuc} 5764684ddb6SLionel Sambuc 5774684ddb6SLionel Sambuctemplate <class _CharT> 5784684ddb6SLionel Sambuc_CharT* 5794684ddb6SLionel Sambucchar_traits<_CharT>::move(char_type* __s1, const char_type* __s2, size_t __n) 5804684ddb6SLionel Sambuc{ 5814684ddb6SLionel Sambuc char_type* __r = __s1; 5824684ddb6SLionel Sambuc if (__s1 < __s2) 5834684ddb6SLionel Sambuc { 5844684ddb6SLionel Sambuc for (; __n; --__n, ++__s1, ++__s2) 5854684ddb6SLionel Sambuc assign(*__s1, *__s2); 5864684ddb6SLionel Sambuc } 5874684ddb6SLionel Sambuc else if (__s2 < __s1) 5884684ddb6SLionel Sambuc { 5894684ddb6SLionel Sambuc __s1 += __n; 5904684ddb6SLionel Sambuc __s2 += __n; 5914684ddb6SLionel Sambuc for (; __n; --__n) 5924684ddb6SLionel Sambuc assign(*--__s1, *--__s2); 5934684ddb6SLionel Sambuc } 5944684ddb6SLionel Sambuc return __r; 5954684ddb6SLionel Sambuc} 5964684ddb6SLionel Sambuc 5974684ddb6SLionel Sambuctemplate <class _CharT> 5984684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 5994684ddb6SLionel Sambuc_CharT* 6004684ddb6SLionel Sambucchar_traits<_CharT>::copy(char_type* __s1, const char_type* __s2, size_t __n) 6014684ddb6SLionel Sambuc{ 6024684ddb6SLionel Sambuc _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); 6034684ddb6SLionel Sambuc char_type* __r = __s1; 6044684ddb6SLionel Sambuc for (; __n; --__n, ++__s1, ++__s2) 6054684ddb6SLionel Sambuc assign(*__s1, *__s2); 6064684ddb6SLionel Sambuc return __r; 6074684ddb6SLionel Sambuc} 6084684ddb6SLionel Sambuc 6094684ddb6SLionel Sambuctemplate <class _CharT> 6104684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 6114684ddb6SLionel Sambuc_CharT* 6124684ddb6SLionel Sambucchar_traits<_CharT>::assign(char_type* __s, size_t __n, char_type __a) 6134684ddb6SLionel Sambuc{ 6144684ddb6SLionel Sambuc char_type* __r = __s; 6154684ddb6SLionel Sambuc for (; __n; --__n, ++__s) 6164684ddb6SLionel Sambuc assign(*__s, __a); 6174684ddb6SLionel Sambuc return __r; 6184684ddb6SLionel Sambuc} 6194684ddb6SLionel Sambuc 6204684ddb6SLionel Sambuc// char_traits<char> 6214684ddb6SLionel Sambuc 6224684ddb6SLionel Sambuctemplate <> 6234684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY char_traits<char> 6244684ddb6SLionel Sambuc{ 6254684ddb6SLionel Sambuc typedef char char_type; 6264684ddb6SLionel Sambuc typedef int int_type; 6274684ddb6SLionel Sambuc typedef streamoff off_type; 6284684ddb6SLionel Sambuc typedef streampos pos_type; 6294684ddb6SLionel Sambuc typedef mbstate_t state_type; 6304684ddb6SLionel Sambuc 631*0a6a1f1dSLionel Sambuc static inline void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT 6324684ddb6SLionel Sambuc {__c1 = __c2;} 633*0a6a1f1dSLionel Sambuc static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT 6344684ddb6SLionel Sambuc {return __c1 == __c2;} 635*0a6a1f1dSLionel Sambuc static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT 6364684ddb6SLionel Sambuc {return (unsigned char)__c1 < (unsigned char)__c2;} 6374684ddb6SLionel Sambuc 638*0a6a1f1dSLionel Sambuc static inline int compare(const char_type* __s1, const char_type* __s2, size_t __n) 639*0a6a1f1dSLionel Sambuc {return __n == 0 ? 0 : memcmp(__s1, __s2, __n);} 640*0a6a1f1dSLionel Sambuc static inline size_t length(const char_type* __s) {return strlen(__s);} 641*0a6a1f1dSLionel Sambuc static inline const char_type* find(const char_type* __s, size_t __n, const char_type& __a) 642*0a6a1f1dSLionel Sambuc {return __n == 0 ? NULL : (const char_type*) memchr(__s, to_int_type(__a), __n);} 643*0a6a1f1dSLionel Sambuc static inline char_type* move(char_type* __s1, const char_type* __s2, size_t __n) 644*0a6a1f1dSLionel Sambuc {return __n == 0 ? __s1 : (char_type*) memmove(__s1, __s2, __n);} 645*0a6a1f1dSLionel Sambuc static inline char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) 6464684ddb6SLionel Sambuc { 6474684ddb6SLionel Sambuc _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); 648*0a6a1f1dSLionel Sambuc return __n == 0 ? __s1 : (char_type*)memcpy(__s1, __s2, __n); 6494684ddb6SLionel Sambuc } 650*0a6a1f1dSLionel Sambuc static inline char_type* assign(char_type* __s, size_t __n, char_type __a) 651*0a6a1f1dSLionel Sambuc {return __n == 0 ? __s : (char_type*)memset(__s, to_int_type(__a), __n);} 6524684ddb6SLionel Sambuc 653*0a6a1f1dSLionel Sambuc static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT 6544684ddb6SLionel Sambuc {return eq_int_type(__c, eof()) ? ~eof() : __c;} 655*0a6a1f1dSLionel Sambuc static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT 6564684ddb6SLionel Sambuc {return char_type(__c);} 657*0a6a1f1dSLionel Sambuc static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT 6584684ddb6SLionel Sambuc {return int_type((unsigned char)__c);} 659*0a6a1f1dSLionel Sambuc static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT 6604684ddb6SLionel Sambuc {return __c1 == __c2;} 661*0a6a1f1dSLionel Sambuc static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT 6624684ddb6SLionel Sambuc {return int_type(EOF);} 6634684ddb6SLionel Sambuc}; 6644684ddb6SLionel Sambuc 6654684ddb6SLionel Sambuc// char_traits<wchar_t> 6664684ddb6SLionel Sambuc 6674684ddb6SLionel Sambuctemplate <> 6684684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY char_traits<wchar_t> 6694684ddb6SLionel Sambuc{ 6704684ddb6SLionel Sambuc typedef wchar_t char_type; 6714684ddb6SLionel Sambuc typedef wint_t int_type; 6724684ddb6SLionel Sambuc typedef streamoff off_type; 6734684ddb6SLionel Sambuc typedef streampos pos_type; 6744684ddb6SLionel Sambuc typedef mbstate_t state_type; 6754684ddb6SLionel Sambuc 676*0a6a1f1dSLionel Sambuc static inline void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT 6774684ddb6SLionel Sambuc {__c1 = __c2;} 678*0a6a1f1dSLionel Sambuc static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT 6794684ddb6SLionel Sambuc {return __c1 == __c2;} 680*0a6a1f1dSLionel Sambuc static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT 6814684ddb6SLionel Sambuc {return __c1 < __c2;} 6824684ddb6SLionel Sambuc 683*0a6a1f1dSLionel Sambuc static inline int compare(const char_type* __s1, const char_type* __s2, size_t __n) 684*0a6a1f1dSLionel Sambuc {return __n == 0 ? 0 : wmemcmp(__s1, __s2, __n);} 685*0a6a1f1dSLionel Sambuc static inline size_t length(const char_type* __s) 6864684ddb6SLionel Sambuc {return wcslen(__s);} 687*0a6a1f1dSLionel Sambuc static inline const char_type* find(const char_type* __s, size_t __n, const char_type& __a) 688*0a6a1f1dSLionel Sambuc {return __n == 0 ? NULL : (const char_type*)wmemchr(__s, __a, __n);} 689*0a6a1f1dSLionel Sambuc static inline char_type* move(char_type* __s1, const char_type* __s2, size_t __n) 690*0a6a1f1dSLionel Sambuc {return __n == 0 ? __s1 : (char_type*)wmemmove(__s1, __s2, __n);} 691*0a6a1f1dSLionel Sambuc static inline char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) 6924684ddb6SLionel Sambuc { 6934684ddb6SLionel Sambuc _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); 694*0a6a1f1dSLionel Sambuc return __n == 0 ? __s1 : (char_type*)wmemcpy(__s1, __s2, __n); 6954684ddb6SLionel Sambuc } 696*0a6a1f1dSLionel Sambuc static inline char_type* assign(char_type* __s, size_t __n, char_type __a) 697*0a6a1f1dSLionel Sambuc {return __n == 0 ? __s : (char_type*)wmemset(__s, __a, __n);} 6984684ddb6SLionel Sambuc 699*0a6a1f1dSLionel Sambuc static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT 7004684ddb6SLionel Sambuc {return eq_int_type(__c, eof()) ? ~eof() : __c;} 701*0a6a1f1dSLionel Sambuc static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT 7024684ddb6SLionel Sambuc {return char_type(__c);} 703*0a6a1f1dSLionel Sambuc static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT 7044684ddb6SLionel Sambuc {return int_type(__c);} 705*0a6a1f1dSLionel Sambuc static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT 7064684ddb6SLionel Sambuc {return __c1 == __c2;} 707*0a6a1f1dSLionel Sambuc static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT 7084684ddb6SLionel Sambuc {return int_type(WEOF);} 7094684ddb6SLionel Sambuc}; 7104684ddb6SLionel Sambuc 7114684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS 7124684ddb6SLionel Sambuc 7134684ddb6SLionel Sambuctemplate <> 7144684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY char_traits<char16_t> 7154684ddb6SLionel Sambuc{ 7164684ddb6SLionel Sambuc typedef char16_t char_type; 7174684ddb6SLionel Sambuc typedef uint_least16_t int_type; 7184684ddb6SLionel Sambuc typedef streamoff off_type; 7194684ddb6SLionel Sambuc typedef u16streampos pos_type; 7204684ddb6SLionel Sambuc typedef mbstate_t state_type; 7214684ddb6SLionel Sambuc 722*0a6a1f1dSLionel Sambuc static inline void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT 7234684ddb6SLionel Sambuc {__c1 = __c2;} 724*0a6a1f1dSLionel Sambuc static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT 7254684ddb6SLionel Sambuc {return __c1 == __c2;} 726*0a6a1f1dSLionel Sambuc static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT 7274684ddb6SLionel Sambuc {return __c1 < __c2;} 7284684ddb6SLionel Sambuc 7294684ddb6SLionel Sambuc static int compare(const char_type* __s1, const char_type* __s2, size_t __n); 7304684ddb6SLionel Sambuc static size_t length(const char_type* __s); 7314684ddb6SLionel Sambuc static const char_type* find(const char_type* __s, size_t __n, const char_type& __a); 7324684ddb6SLionel Sambuc static char_type* move(char_type* __s1, const char_type* __s2, size_t __n); 7334684ddb6SLionel Sambuc static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n); 7344684ddb6SLionel Sambuc static char_type* assign(char_type* __s, size_t __n, char_type __a); 7354684ddb6SLionel Sambuc 736*0a6a1f1dSLionel Sambuc static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT 7374684ddb6SLionel Sambuc {return eq_int_type(__c, eof()) ? ~eof() : __c;} 738*0a6a1f1dSLionel Sambuc static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT 7394684ddb6SLionel Sambuc {return char_type(__c);} 740*0a6a1f1dSLionel Sambuc static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT 7414684ddb6SLionel Sambuc {return int_type(__c);} 742*0a6a1f1dSLionel Sambuc static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT 7434684ddb6SLionel Sambuc {return __c1 == __c2;} 744*0a6a1f1dSLionel Sambuc static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT 745*0a6a1f1dSLionel Sambuc {return int_type(0xFFFF);} 7464684ddb6SLionel Sambuc}; 7474684ddb6SLionel Sambuc 7484684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 7494684ddb6SLionel Sambucint 7504684ddb6SLionel Sambucchar_traits<char16_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) 7514684ddb6SLionel Sambuc{ 7524684ddb6SLionel Sambuc for (; __n; --__n, ++__s1, ++__s2) 7534684ddb6SLionel Sambuc { 7544684ddb6SLionel Sambuc if (lt(*__s1, *__s2)) 7554684ddb6SLionel Sambuc return -1; 7564684ddb6SLionel Sambuc if (lt(*__s2, *__s1)) 7574684ddb6SLionel Sambuc return 1; 7584684ddb6SLionel Sambuc } 7594684ddb6SLionel Sambuc return 0; 7604684ddb6SLionel Sambuc} 7614684ddb6SLionel Sambuc 7624684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 7634684ddb6SLionel Sambucsize_t 7644684ddb6SLionel Sambucchar_traits<char16_t>::length(const char_type* __s) 7654684ddb6SLionel Sambuc{ 7664684ddb6SLionel Sambuc size_t __len = 0; 7674684ddb6SLionel Sambuc for (; !eq(*__s, char_type(0)); ++__s) 7684684ddb6SLionel Sambuc ++__len; 7694684ddb6SLionel Sambuc return __len; 7704684ddb6SLionel Sambuc} 7714684ddb6SLionel Sambuc 7724684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 7734684ddb6SLionel Sambucconst char16_t* 7744684ddb6SLionel Sambucchar_traits<char16_t>::find(const char_type* __s, size_t __n, const char_type& __a) 7754684ddb6SLionel Sambuc{ 7764684ddb6SLionel Sambuc for (; __n; --__n) 7774684ddb6SLionel Sambuc { 7784684ddb6SLionel Sambuc if (eq(*__s, __a)) 7794684ddb6SLionel Sambuc return __s; 7804684ddb6SLionel Sambuc ++__s; 7814684ddb6SLionel Sambuc } 7824684ddb6SLionel Sambuc return 0; 7834684ddb6SLionel Sambuc} 7844684ddb6SLionel Sambuc 7854684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 7864684ddb6SLionel Sambucchar16_t* 7874684ddb6SLionel Sambucchar_traits<char16_t>::move(char_type* __s1, const char_type* __s2, size_t __n) 7884684ddb6SLionel Sambuc{ 7894684ddb6SLionel Sambuc char_type* __r = __s1; 7904684ddb6SLionel Sambuc if (__s1 < __s2) 7914684ddb6SLionel Sambuc { 7924684ddb6SLionel Sambuc for (; __n; --__n, ++__s1, ++__s2) 7934684ddb6SLionel Sambuc assign(*__s1, *__s2); 7944684ddb6SLionel Sambuc } 7954684ddb6SLionel Sambuc else if (__s2 < __s1) 7964684ddb6SLionel Sambuc { 7974684ddb6SLionel Sambuc __s1 += __n; 7984684ddb6SLionel Sambuc __s2 += __n; 7994684ddb6SLionel Sambuc for (; __n; --__n) 8004684ddb6SLionel Sambuc assign(*--__s1, *--__s2); 8014684ddb6SLionel Sambuc } 8024684ddb6SLionel Sambuc return __r; 8034684ddb6SLionel Sambuc} 8044684ddb6SLionel Sambuc 8054684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 8064684ddb6SLionel Sambucchar16_t* 8074684ddb6SLionel Sambucchar_traits<char16_t>::copy(char_type* __s1, const char_type* __s2, size_t __n) 8084684ddb6SLionel Sambuc{ 8094684ddb6SLionel Sambuc _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); 8104684ddb6SLionel Sambuc char_type* __r = __s1; 8114684ddb6SLionel Sambuc for (; __n; --__n, ++__s1, ++__s2) 8124684ddb6SLionel Sambuc assign(*__s1, *__s2); 8134684ddb6SLionel Sambuc return __r; 8144684ddb6SLionel Sambuc} 8154684ddb6SLionel Sambuc 8164684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 8174684ddb6SLionel Sambucchar16_t* 8184684ddb6SLionel Sambucchar_traits<char16_t>::assign(char_type* __s, size_t __n, char_type __a) 8194684ddb6SLionel Sambuc{ 8204684ddb6SLionel Sambuc char_type* __r = __s; 8214684ddb6SLionel Sambuc for (; __n; --__n, ++__s) 8224684ddb6SLionel Sambuc assign(*__s, __a); 8234684ddb6SLionel Sambuc return __r; 8244684ddb6SLionel Sambuc} 8254684ddb6SLionel Sambuc 8264684ddb6SLionel Sambuctemplate <> 8274684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY char_traits<char32_t> 8284684ddb6SLionel Sambuc{ 8294684ddb6SLionel Sambuc typedef char32_t char_type; 8304684ddb6SLionel Sambuc typedef uint_least32_t int_type; 8314684ddb6SLionel Sambuc typedef streamoff off_type; 8324684ddb6SLionel Sambuc typedef u32streampos pos_type; 8334684ddb6SLionel Sambuc typedef mbstate_t state_type; 8344684ddb6SLionel Sambuc 835*0a6a1f1dSLionel Sambuc static inline void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT 8364684ddb6SLionel Sambuc {__c1 = __c2;} 837*0a6a1f1dSLionel Sambuc static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT 8384684ddb6SLionel Sambuc {return __c1 == __c2;} 839*0a6a1f1dSLionel Sambuc static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT 8404684ddb6SLionel Sambuc {return __c1 < __c2;} 8414684ddb6SLionel Sambuc 8424684ddb6SLionel Sambuc static int compare(const char_type* __s1, const char_type* __s2, size_t __n); 8434684ddb6SLionel Sambuc static size_t length(const char_type* __s); 8444684ddb6SLionel Sambuc static const char_type* find(const char_type* __s, size_t __n, const char_type& __a); 8454684ddb6SLionel Sambuc static char_type* move(char_type* __s1, const char_type* __s2, size_t __n); 8464684ddb6SLionel Sambuc static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n); 8474684ddb6SLionel Sambuc static char_type* assign(char_type* __s, size_t __n, char_type __a); 8484684ddb6SLionel Sambuc 849*0a6a1f1dSLionel Sambuc static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT 8504684ddb6SLionel Sambuc {return eq_int_type(__c, eof()) ? ~eof() : __c;} 851*0a6a1f1dSLionel Sambuc static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT 8524684ddb6SLionel Sambuc {return char_type(__c);} 853*0a6a1f1dSLionel Sambuc static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT 8544684ddb6SLionel Sambuc {return int_type(__c);} 855*0a6a1f1dSLionel Sambuc static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT 8564684ddb6SLionel Sambuc {return __c1 == __c2;} 857*0a6a1f1dSLionel Sambuc static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT 8584684ddb6SLionel Sambuc {return int_type(0xFFFFFFFF);} 8594684ddb6SLionel Sambuc}; 8604684ddb6SLionel Sambuc 8614684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 8624684ddb6SLionel Sambucint 8634684ddb6SLionel Sambucchar_traits<char32_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) 8644684ddb6SLionel Sambuc{ 8654684ddb6SLionel Sambuc for (; __n; --__n, ++__s1, ++__s2) 8664684ddb6SLionel Sambuc { 8674684ddb6SLionel Sambuc if (lt(*__s1, *__s2)) 8684684ddb6SLionel Sambuc return -1; 8694684ddb6SLionel Sambuc if (lt(*__s2, *__s1)) 8704684ddb6SLionel Sambuc return 1; 8714684ddb6SLionel Sambuc } 8724684ddb6SLionel Sambuc return 0; 8734684ddb6SLionel Sambuc} 8744684ddb6SLionel Sambuc 8754684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 8764684ddb6SLionel Sambucsize_t 8774684ddb6SLionel Sambucchar_traits<char32_t>::length(const char_type* __s) 8784684ddb6SLionel Sambuc{ 8794684ddb6SLionel Sambuc size_t __len = 0; 8804684ddb6SLionel Sambuc for (; !eq(*__s, char_type(0)); ++__s) 8814684ddb6SLionel Sambuc ++__len; 8824684ddb6SLionel Sambuc return __len; 8834684ddb6SLionel Sambuc} 8844684ddb6SLionel Sambuc 8854684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 8864684ddb6SLionel Sambucconst char32_t* 8874684ddb6SLionel Sambucchar_traits<char32_t>::find(const char_type* __s, size_t __n, const char_type& __a) 8884684ddb6SLionel Sambuc{ 8894684ddb6SLionel Sambuc for (; __n; --__n) 8904684ddb6SLionel Sambuc { 8914684ddb6SLionel Sambuc if (eq(*__s, __a)) 8924684ddb6SLionel Sambuc return __s; 8934684ddb6SLionel Sambuc ++__s; 8944684ddb6SLionel Sambuc } 8954684ddb6SLionel Sambuc return 0; 8964684ddb6SLionel Sambuc} 8974684ddb6SLionel Sambuc 8984684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 8994684ddb6SLionel Sambucchar32_t* 9004684ddb6SLionel Sambucchar_traits<char32_t>::move(char_type* __s1, const char_type* __s2, size_t __n) 9014684ddb6SLionel Sambuc{ 9024684ddb6SLionel Sambuc char_type* __r = __s1; 9034684ddb6SLionel Sambuc if (__s1 < __s2) 9044684ddb6SLionel Sambuc { 9054684ddb6SLionel Sambuc for (; __n; --__n, ++__s1, ++__s2) 9064684ddb6SLionel Sambuc assign(*__s1, *__s2); 9074684ddb6SLionel Sambuc } 9084684ddb6SLionel Sambuc else if (__s2 < __s1) 9094684ddb6SLionel Sambuc { 9104684ddb6SLionel Sambuc __s1 += __n; 9114684ddb6SLionel Sambuc __s2 += __n; 9124684ddb6SLionel Sambuc for (; __n; --__n) 9134684ddb6SLionel Sambuc assign(*--__s1, *--__s2); 9144684ddb6SLionel Sambuc } 9154684ddb6SLionel Sambuc return __r; 9164684ddb6SLionel Sambuc} 9174684ddb6SLionel Sambuc 9184684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 9194684ddb6SLionel Sambucchar32_t* 9204684ddb6SLionel Sambucchar_traits<char32_t>::copy(char_type* __s1, const char_type* __s2, size_t __n) 9214684ddb6SLionel Sambuc{ 9224684ddb6SLionel Sambuc _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); 9234684ddb6SLionel Sambuc char_type* __r = __s1; 9244684ddb6SLionel Sambuc for (; __n; --__n, ++__s1, ++__s2) 9254684ddb6SLionel Sambuc assign(*__s1, *__s2); 9264684ddb6SLionel Sambuc return __r; 9274684ddb6SLionel Sambuc} 9284684ddb6SLionel Sambuc 9294684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 9304684ddb6SLionel Sambucchar32_t* 9314684ddb6SLionel Sambucchar_traits<char32_t>::assign(char_type* __s, size_t __n, char_type __a) 9324684ddb6SLionel Sambuc{ 9334684ddb6SLionel Sambuc char_type* __r = __s; 9344684ddb6SLionel Sambuc for (; __n; --__n, ++__s) 9354684ddb6SLionel Sambuc assign(*__s, __a); 9364684ddb6SLionel Sambuc return __r; 9374684ddb6SLionel Sambuc} 9384684ddb6SLionel Sambuc 9394684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_UNICODE_CHARS 9404684ddb6SLionel Sambuc 941*0a6a1f1dSLionel Sambuc// helper fns for basic_string 942*0a6a1f1dSLionel Sambuc 943*0a6a1f1dSLionel Sambuc// __str_find 944*0a6a1f1dSLionel Sambuctemplate<class _CharT, class _SizeT, class _Traits, _SizeT __npos> 945*0a6a1f1dSLionel Sambuc_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 946*0a6a1f1dSLionel Sambuc__str_find(const _CharT *__p, _SizeT __sz, 947*0a6a1f1dSLionel Sambuc _CharT __c, _SizeT __pos) _NOEXCEPT 948*0a6a1f1dSLionel Sambuc{ 949*0a6a1f1dSLionel Sambuc if (__pos >= __sz) 950*0a6a1f1dSLionel Sambuc return __npos; 951*0a6a1f1dSLionel Sambuc const _CharT* __r = _Traits::find(__p + __pos, __sz - __pos, __c); 952*0a6a1f1dSLionel Sambuc if (__r == 0) 953*0a6a1f1dSLionel Sambuc return __npos; 954*0a6a1f1dSLionel Sambuc return static_cast<_SizeT>(__r - __p); 955*0a6a1f1dSLionel Sambuc} 956*0a6a1f1dSLionel Sambuc 957*0a6a1f1dSLionel Sambuctemplate<class _CharT, class _SizeT, class _Traits, _SizeT __npos> 958*0a6a1f1dSLionel Sambuc_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 959*0a6a1f1dSLionel Sambuc__str_find(const _CharT *__p, _SizeT __sz, 960*0a6a1f1dSLionel Sambuc const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT 961*0a6a1f1dSLionel Sambuc{ 962*0a6a1f1dSLionel Sambuc if (__pos > __sz || __sz - __pos < __n) 963*0a6a1f1dSLionel Sambuc return __npos; 964*0a6a1f1dSLionel Sambuc if (__n == 0) 965*0a6a1f1dSLionel Sambuc return __pos; 966*0a6a1f1dSLionel Sambuc const _CharT* __r = 967*0a6a1f1dSLionel Sambuc _VSTD::__search(__p + __pos, __p + __sz, 968*0a6a1f1dSLionel Sambuc __s, __s + __n, _Traits::eq, 969*0a6a1f1dSLionel Sambuc random_access_iterator_tag(), random_access_iterator_tag()); 970*0a6a1f1dSLionel Sambuc if (__r == __p + __sz) 971*0a6a1f1dSLionel Sambuc return __npos; 972*0a6a1f1dSLionel Sambuc return static_cast<_SizeT>(__r - __p); 973*0a6a1f1dSLionel Sambuc} 974*0a6a1f1dSLionel Sambuc 975*0a6a1f1dSLionel Sambuc 976*0a6a1f1dSLionel Sambuc// __str_rfind 977*0a6a1f1dSLionel Sambuc 978*0a6a1f1dSLionel Sambuctemplate<class _CharT, class _SizeT, class _Traits, _SizeT __npos> 979*0a6a1f1dSLionel Sambuc_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 980*0a6a1f1dSLionel Sambuc__str_rfind(const _CharT *__p, _SizeT __sz, 981*0a6a1f1dSLionel Sambuc _CharT __c, _SizeT __pos) _NOEXCEPT 982*0a6a1f1dSLionel Sambuc{ 983*0a6a1f1dSLionel Sambuc if (__sz < 1) 984*0a6a1f1dSLionel Sambuc return __npos; 985*0a6a1f1dSLionel Sambuc if (__pos < __sz) 986*0a6a1f1dSLionel Sambuc ++__pos; 987*0a6a1f1dSLionel Sambuc else 988*0a6a1f1dSLionel Sambuc __pos = __sz; 989*0a6a1f1dSLionel Sambuc for (const _CharT* __ps = __p + __pos; __ps != __p;) 990*0a6a1f1dSLionel Sambuc { 991*0a6a1f1dSLionel Sambuc if (_Traits::eq(*--__ps, __c)) 992*0a6a1f1dSLionel Sambuc return static_cast<_SizeT>(__ps - __p); 993*0a6a1f1dSLionel Sambuc } 994*0a6a1f1dSLionel Sambuc return __npos; 995*0a6a1f1dSLionel Sambuc} 996*0a6a1f1dSLionel Sambuc 997*0a6a1f1dSLionel Sambuctemplate<class _CharT, class _SizeT, class _Traits, _SizeT __npos> 998*0a6a1f1dSLionel Sambuc_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 999*0a6a1f1dSLionel Sambuc__str_rfind(const _CharT *__p, _SizeT __sz, 1000*0a6a1f1dSLionel Sambuc const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT 1001*0a6a1f1dSLionel Sambuc{ 1002*0a6a1f1dSLionel Sambuc __pos = _VSTD::min(__pos, __sz); 1003*0a6a1f1dSLionel Sambuc if (__n < __sz - __pos) 1004*0a6a1f1dSLionel Sambuc __pos += __n; 1005*0a6a1f1dSLionel Sambuc else 1006*0a6a1f1dSLionel Sambuc __pos = __sz; 1007*0a6a1f1dSLionel Sambuc const _CharT* __r = _VSTD::__find_end( 1008*0a6a1f1dSLionel Sambuc __p, __p + __pos, __s, __s + __n, _Traits::eq, 1009*0a6a1f1dSLionel Sambuc random_access_iterator_tag(), random_access_iterator_tag()); 1010*0a6a1f1dSLionel Sambuc if (__n > 0 && __r == __p + __pos) 1011*0a6a1f1dSLionel Sambuc return __npos; 1012*0a6a1f1dSLionel Sambuc return static_cast<_SizeT>(__r - __p); 1013*0a6a1f1dSLionel Sambuc} 1014*0a6a1f1dSLionel Sambuc 1015*0a6a1f1dSLionel Sambuc// __str_find_first_of 1016*0a6a1f1dSLionel Sambuctemplate<class _CharT, class _SizeT, class _Traits, _SizeT __npos> 1017*0a6a1f1dSLionel Sambuc_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 1018*0a6a1f1dSLionel Sambuc__str_find_first_of(const _CharT *__p, _SizeT __sz, 1019*0a6a1f1dSLionel Sambuc const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT 1020*0a6a1f1dSLionel Sambuc{ 1021*0a6a1f1dSLionel Sambuc if (__pos >= __sz || __n == 0) 1022*0a6a1f1dSLionel Sambuc return __npos; 1023*0a6a1f1dSLionel Sambuc const _CharT* __r = _VSTD::__find_first_of_ce 1024*0a6a1f1dSLionel Sambuc (__p + __pos, __p + __sz, __s, __s + __n, _Traits::eq ); 1025*0a6a1f1dSLionel Sambuc if (__r == __p + __sz) 1026*0a6a1f1dSLionel Sambuc return __npos; 1027*0a6a1f1dSLionel Sambuc return static_cast<_SizeT>(__r - __p); 1028*0a6a1f1dSLionel Sambuc} 1029*0a6a1f1dSLionel Sambuc 1030*0a6a1f1dSLionel Sambuc 1031*0a6a1f1dSLionel Sambuc// __str_find_last_of 1032*0a6a1f1dSLionel Sambuctemplate<class _CharT, class _SizeT, class _Traits, _SizeT __npos> 1033*0a6a1f1dSLionel Sambuc_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 1034*0a6a1f1dSLionel Sambuc__str_find_last_of(const _CharT *__p, _SizeT __sz, 1035*0a6a1f1dSLionel Sambuc const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT 1036*0a6a1f1dSLionel Sambuc { 1037*0a6a1f1dSLionel Sambuc if (__n != 0) 1038*0a6a1f1dSLionel Sambuc { 1039*0a6a1f1dSLionel Sambuc if (__pos < __sz) 1040*0a6a1f1dSLionel Sambuc ++__pos; 1041*0a6a1f1dSLionel Sambuc else 1042*0a6a1f1dSLionel Sambuc __pos = __sz; 1043*0a6a1f1dSLionel Sambuc for (const _CharT* __ps = __p + __pos; __ps != __p;) 1044*0a6a1f1dSLionel Sambuc { 1045*0a6a1f1dSLionel Sambuc const _CharT* __r = _Traits::find(__s, __n, *--__ps); 1046*0a6a1f1dSLionel Sambuc if (__r) 1047*0a6a1f1dSLionel Sambuc return static_cast<_SizeT>(__ps - __p); 1048*0a6a1f1dSLionel Sambuc } 1049*0a6a1f1dSLionel Sambuc } 1050*0a6a1f1dSLionel Sambuc return __npos; 1051*0a6a1f1dSLionel Sambuc} 1052*0a6a1f1dSLionel Sambuc 1053*0a6a1f1dSLionel Sambuc 1054*0a6a1f1dSLionel Sambuc// __str_find_first_not_of 1055*0a6a1f1dSLionel Sambuctemplate<class _CharT, class _SizeT, class _Traits, _SizeT __npos> 1056*0a6a1f1dSLionel Sambuc_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 1057*0a6a1f1dSLionel Sambuc__str_find_first_not_of(const _CharT *__p, _SizeT __sz, 1058*0a6a1f1dSLionel Sambuc const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT 1059*0a6a1f1dSLionel Sambuc{ 1060*0a6a1f1dSLionel Sambuc if (__pos < __sz) 1061*0a6a1f1dSLionel Sambuc { 1062*0a6a1f1dSLionel Sambuc const _CharT* __pe = __p + __sz; 1063*0a6a1f1dSLionel Sambuc for (const _CharT* __ps = __p + __pos; __ps != __pe; ++__ps) 1064*0a6a1f1dSLionel Sambuc if (_Traits::find(__s, __n, *__ps) == 0) 1065*0a6a1f1dSLionel Sambuc return static_cast<_SizeT>(__ps - __p); 1066*0a6a1f1dSLionel Sambuc } 1067*0a6a1f1dSLionel Sambuc return __npos; 1068*0a6a1f1dSLionel Sambuc} 1069*0a6a1f1dSLionel Sambuc 1070*0a6a1f1dSLionel Sambuc 1071*0a6a1f1dSLionel Sambuctemplate<class _CharT, class _SizeT, class _Traits, _SizeT __npos> 1072*0a6a1f1dSLionel Sambuc_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 1073*0a6a1f1dSLionel Sambuc__str_find_first_not_of(const _CharT *__p, _SizeT __sz, 1074*0a6a1f1dSLionel Sambuc _CharT __c, _SizeT __pos) _NOEXCEPT 1075*0a6a1f1dSLionel Sambuc{ 1076*0a6a1f1dSLionel Sambuc if (__pos < __sz) 1077*0a6a1f1dSLionel Sambuc { 1078*0a6a1f1dSLionel Sambuc const _CharT* __pe = __p + __sz; 1079*0a6a1f1dSLionel Sambuc for (const _CharT* __ps = __p + __pos; __ps != __pe; ++__ps) 1080*0a6a1f1dSLionel Sambuc if (!_Traits::eq(*__ps, __c)) 1081*0a6a1f1dSLionel Sambuc return static_cast<_SizeT>(__ps - __p); 1082*0a6a1f1dSLionel Sambuc } 1083*0a6a1f1dSLionel Sambuc return __npos; 1084*0a6a1f1dSLionel Sambuc} 1085*0a6a1f1dSLionel Sambuc 1086*0a6a1f1dSLionel Sambuc 1087*0a6a1f1dSLionel Sambuc// __str_find_last_not_of 1088*0a6a1f1dSLionel Sambuctemplate<class _CharT, class _SizeT, class _Traits, _SizeT __npos> 1089*0a6a1f1dSLionel Sambuc_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 1090*0a6a1f1dSLionel Sambuc__str_find_last_not_of(const _CharT *__p, _SizeT __sz, 1091*0a6a1f1dSLionel Sambuc const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT 1092*0a6a1f1dSLionel Sambuc{ 1093*0a6a1f1dSLionel Sambuc if (__pos < __sz) 1094*0a6a1f1dSLionel Sambuc ++__pos; 1095*0a6a1f1dSLionel Sambuc else 1096*0a6a1f1dSLionel Sambuc __pos = __sz; 1097*0a6a1f1dSLionel Sambuc for (const _CharT* __ps = __p + __pos; __ps != __p;) 1098*0a6a1f1dSLionel Sambuc if (_Traits::find(__s, __n, *--__ps) == 0) 1099*0a6a1f1dSLionel Sambuc return static_cast<_SizeT>(__ps - __p); 1100*0a6a1f1dSLionel Sambuc return __npos; 1101*0a6a1f1dSLionel Sambuc} 1102*0a6a1f1dSLionel Sambuc 1103*0a6a1f1dSLionel Sambuc 1104*0a6a1f1dSLionel Sambuctemplate<class _CharT, class _SizeT, class _Traits, _SizeT __npos> 1105*0a6a1f1dSLionel Sambuc_SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY 1106*0a6a1f1dSLionel Sambuc__str_find_last_not_of(const _CharT *__p, _SizeT __sz, 1107*0a6a1f1dSLionel Sambuc _CharT __c, _SizeT __pos) _NOEXCEPT 1108*0a6a1f1dSLionel Sambuc{ 1109*0a6a1f1dSLionel Sambuc if (__pos < __sz) 1110*0a6a1f1dSLionel Sambuc ++__pos; 1111*0a6a1f1dSLionel Sambuc else 1112*0a6a1f1dSLionel Sambuc __pos = __sz; 1113*0a6a1f1dSLionel Sambuc for (const _CharT* __ps = __p + __pos; __ps != __p;) 1114*0a6a1f1dSLionel Sambuc if (!_Traits::eq(*--__ps, __c)) 1115*0a6a1f1dSLionel Sambuc return static_cast<_SizeT>(__ps - __p); 1116*0a6a1f1dSLionel Sambuc return __npos; 1117*0a6a1f1dSLionel Sambuc} 1118*0a6a1f1dSLionel Sambuc 1119*0a6a1f1dSLionel Sambuctemplate<class _Ptr> 1120*0a6a1f1dSLionel Sambucsize_t _LIBCPP_INLINE_VISIBILITY __do_string_hash(_Ptr __p, _Ptr __e) 1121*0a6a1f1dSLionel Sambuc{ 1122*0a6a1f1dSLionel Sambuc typedef typename iterator_traits<_Ptr>::value_type value_type; 1123*0a6a1f1dSLionel Sambuc return __murmur2_or_cityhash<size_t>()(__p, (__e-__p)*sizeof(value_type)); 1124*0a6a1f1dSLionel Sambuc} 1125*0a6a1f1dSLionel Sambuc 11264684ddb6SLionel Sambuc// basic_string 11274684ddb6SLionel Sambuc 11284684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 11294684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator> 11304684ddb6SLionel Sambucoperator+(const basic_string<_CharT, _Traits, _Allocator>& __x, 11314684ddb6SLionel Sambuc const basic_string<_CharT, _Traits, _Allocator>& __y); 11324684ddb6SLionel Sambuc 11334684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 11344684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator> 11354684ddb6SLionel Sambucoperator+(const _CharT* __x, const basic_string<_CharT,_Traits,_Allocator>& __y); 11364684ddb6SLionel Sambuc 11374684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 11384684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator> 11394684ddb6SLionel Sambucoperator+(_CharT __x, const basic_string<_CharT,_Traits,_Allocator>& __y); 11404684ddb6SLionel Sambuc 11414684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 11424684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator> 11434684ddb6SLionel Sambucoperator+(const basic_string<_CharT, _Traits, _Allocator>& __x, const _CharT* __y); 11444684ddb6SLionel Sambuc 11454684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 11464684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator> 11474684ddb6SLionel Sambucoperator+(const basic_string<_CharT, _Traits, _Allocator>& __x, _CharT __y); 11484684ddb6SLionel Sambuc 11494684ddb6SLionel Sambuctemplate <bool> 11504684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY __basic_string_common 11514684ddb6SLionel Sambuc{ 11524684ddb6SLionel Sambucprotected: 11534684ddb6SLionel Sambuc void __throw_length_error() const; 11544684ddb6SLionel Sambuc void __throw_out_of_range() const; 11554684ddb6SLionel Sambuc}; 11564684ddb6SLionel Sambuc 11574684ddb6SLionel Sambuctemplate <bool __b> 11584684ddb6SLionel Sambucvoid 11594684ddb6SLionel Sambuc__basic_string_common<__b>::__throw_length_error() const 11604684ddb6SLionel Sambuc{ 11614684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 11624684ddb6SLionel Sambuc throw length_error("basic_string"); 11634684ddb6SLionel Sambuc#else 11644684ddb6SLionel Sambuc assert(!"basic_string length_error"); 11654684ddb6SLionel Sambuc#endif 11664684ddb6SLionel Sambuc} 11674684ddb6SLionel Sambuc 11684684ddb6SLionel Sambuctemplate <bool __b> 11694684ddb6SLionel Sambucvoid 11704684ddb6SLionel Sambuc__basic_string_common<__b>::__throw_out_of_range() const 11714684ddb6SLionel Sambuc{ 11724684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 11734684ddb6SLionel Sambuc throw out_of_range("basic_string"); 11744684ddb6SLionel Sambuc#else 11754684ddb6SLionel Sambuc assert(!"basic_string out_of_range"); 11764684ddb6SLionel Sambuc#endif 11774684ddb6SLionel Sambuc} 11784684ddb6SLionel Sambuc 11794684ddb6SLionel Sambuc#ifdef _LIBCPP_MSVC 11804684ddb6SLionel Sambuc#pragma warning( push ) 11814684ddb6SLionel Sambuc#pragma warning( disable: 4231 ) 11824684ddb6SLionel Sambuc#endif // _LIBCPP_MSVC 11834684ddb6SLionel Sambuc_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS __basic_string_common<true>) 11844684ddb6SLionel Sambuc#ifdef _LIBCPP_MSVC 11854684ddb6SLionel Sambuc#pragma warning( pop ) 11864684ddb6SLionel Sambuc#endif // _LIBCPP_MSVC 11874684ddb6SLionel Sambuc 11884684ddb6SLionel Sambuc#ifdef _LIBCPP_ALTERNATE_STRING_LAYOUT 11894684ddb6SLionel Sambuc 11904684ddb6SLionel Sambuctemplate <class _CharT, size_t = sizeof(_CharT)> 11914684ddb6SLionel Sambucstruct __padding 11924684ddb6SLionel Sambuc{ 11934684ddb6SLionel Sambuc unsigned char __xx[sizeof(_CharT)-1]; 11944684ddb6SLionel Sambuc}; 11954684ddb6SLionel Sambuc 11964684ddb6SLionel Sambuctemplate <class _CharT> 11974684ddb6SLionel Sambucstruct __padding<_CharT, 1> 11984684ddb6SLionel Sambuc{ 11994684ddb6SLionel Sambuc}; 12004684ddb6SLionel Sambuc 12014684ddb6SLionel Sambuc#endif // _LIBCPP_ALTERNATE_STRING_LAYOUT 12024684ddb6SLionel Sambuc 12034684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 12044684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY basic_string 12054684ddb6SLionel Sambuc : private __basic_string_common<true> 12064684ddb6SLionel Sambuc{ 12074684ddb6SLionel Sambucpublic: 12084684ddb6SLionel Sambuc typedef basic_string __self; 12094684ddb6SLionel Sambuc typedef _Traits traits_type; 12104684ddb6SLionel Sambuc typedef typename traits_type::char_type value_type; 12114684ddb6SLionel Sambuc typedef _Allocator allocator_type; 12124684ddb6SLionel Sambuc typedef allocator_traits<allocator_type> __alloc_traits; 12134684ddb6SLionel Sambuc typedef typename __alloc_traits::size_type size_type; 12144684ddb6SLionel Sambuc typedef typename __alloc_traits::difference_type difference_type; 12154684ddb6SLionel Sambuc typedef value_type& reference; 12164684ddb6SLionel Sambuc typedef const value_type& const_reference; 12174684ddb6SLionel Sambuc typedef typename __alloc_traits::pointer pointer; 12184684ddb6SLionel Sambuc typedef typename __alloc_traits::const_pointer const_pointer; 12194684ddb6SLionel Sambuc 12204684ddb6SLionel Sambuc static_assert(is_pod<value_type>::value, "Character type of basic_string must be a POD"); 12214684ddb6SLionel Sambuc static_assert((is_same<_CharT, value_type>::value), 12224684ddb6SLionel Sambuc "traits_type::char_type must be the same type as CharT"); 12234684ddb6SLionel Sambuc static_assert((is_same<typename allocator_type::value_type, value_type>::value), 12244684ddb6SLionel Sambuc "Allocator::value_type must be same type as value_type"); 12254684ddb6SLionel Sambuc#if defined(_LIBCPP_RAW_ITERATORS) 12264684ddb6SLionel Sambuc typedef pointer iterator; 12274684ddb6SLionel Sambuc typedef const_pointer const_iterator; 12284684ddb6SLionel Sambuc#else // defined(_LIBCPP_RAW_ITERATORS) 12294684ddb6SLionel Sambuc typedef __wrap_iter<pointer> iterator; 12304684ddb6SLionel Sambuc typedef __wrap_iter<const_pointer> const_iterator; 12314684ddb6SLionel Sambuc#endif // defined(_LIBCPP_RAW_ITERATORS) 12324684ddb6SLionel Sambuc typedef _VSTD::reverse_iterator<iterator> reverse_iterator; 12334684ddb6SLionel Sambuc typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; 12344684ddb6SLionel Sambuc 12354684ddb6SLionel Sambucprivate: 12364684ddb6SLionel Sambuc 12374684ddb6SLionel Sambuc#ifdef _LIBCPP_ALTERNATE_STRING_LAYOUT 12384684ddb6SLionel Sambuc 12394684ddb6SLionel Sambuc struct __long 12404684ddb6SLionel Sambuc { 12414684ddb6SLionel Sambuc pointer __data_; 12424684ddb6SLionel Sambuc size_type __size_; 12434684ddb6SLionel Sambuc size_type __cap_; 12444684ddb6SLionel Sambuc }; 12454684ddb6SLionel Sambuc 12464684ddb6SLionel Sambuc#if _LIBCPP_BIG_ENDIAN 12474684ddb6SLionel Sambuc enum {__short_mask = 0x01}; 12484684ddb6SLionel Sambuc enum {__long_mask = 0x1ul}; 12494684ddb6SLionel Sambuc#else // _LIBCPP_BIG_ENDIAN 12504684ddb6SLionel Sambuc enum {__short_mask = 0x80}; 12514684ddb6SLionel Sambuc enum {__long_mask = ~(size_type(~0) >> 1)}; 12524684ddb6SLionel Sambuc#endif // _LIBCPP_BIG_ENDIAN 12534684ddb6SLionel Sambuc 12544684ddb6SLionel Sambuc enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ? 12554684ddb6SLionel Sambuc (sizeof(__long) - 1)/sizeof(value_type) : 2}; 12564684ddb6SLionel Sambuc 12574684ddb6SLionel Sambuc struct __short 12584684ddb6SLionel Sambuc { 12594684ddb6SLionel Sambuc value_type __data_[__min_cap]; 12604684ddb6SLionel Sambuc struct 12614684ddb6SLionel Sambuc : __padding<value_type> 12624684ddb6SLionel Sambuc { 12634684ddb6SLionel Sambuc unsigned char __size_; 12644684ddb6SLionel Sambuc }; 12654684ddb6SLionel Sambuc }; 12664684ddb6SLionel Sambuc 12674684ddb6SLionel Sambuc#else 12684684ddb6SLionel Sambuc 12694684ddb6SLionel Sambuc struct __long 12704684ddb6SLionel Sambuc { 12714684ddb6SLionel Sambuc size_type __cap_; 12724684ddb6SLionel Sambuc size_type __size_; 12734684ddb6SLionel Sambuc pointer __data_; 12744684ddb6SLionel Sambuc }; 12754684ddb6SLionel Sambuc 12764684ddb6SLionel Sambuc#if _LIBCPP_BIG_ENDIAN 12774684ddb6SLionel Sambuc enum {__short_mask = 0x80}; 12784684ddb6SLionel Sambuc enum {__long_mask = ~(size_type(~0) >> 1)}; 12794684ddb6SLionel Sambuc#else // _LIBCPP_BIG_ENDIAN 12804684ddb6SLionel Sambuc enum {__short_mask = 0x01}; 12814684ddb6SLionel Sambuc enum {__long_mask = 0x1ul}; 12824684ddb6SLionel Sambuc#endif // _LIBCPP_BIG_ENDIAN 12834684ddb6SLionel Sambuc 12844684ddb6SLionel Sambuc enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ? 12854684ddb6SLionel Sambuc (sizeof(__long) - 1)/sizeof(value_type) : 2}; 12864684ddb6SLionel Sambuc 12874684ddb6SLionel Sambuc struct __short 12884684ddb6SLionel Sambuc { 12894684ddb6SLionel Sambuc union 12904684ddb6SLionel Sambuc { 12914684ddb6SLionel Sambuc unsigned char __size_; 12924684ddb6SLionel Sambuc value_type __lx; 12934684ddb6SLionel Sambuc }; 12944684ddb6SLionel Sambuc value_type __data_[__min_cap]; 12954684ddb6SLionel Sambuc }; 12964684ddb6SLionel Sambuc 12974684ddb6SLionel Sambuc#endif // _LIBCPP_ALTERNATE_STRING_LAYOUT 12984684ddb6SLionel Sambuc 12994684ddb6SLionel Sambuc union __ulx{__long __lx; __short __lxx;}; 13004684ddb6SLionel Sambuc 13014684ddb6SLionel Sambuc enum {__n_words = sizeof(__ulx) / sizeof(size_type)}; 13024684ddb6SLionel Sambuc 13034684ddb6SLionel Sambuc struct __raw 13044684ddb6SLionel Sambuc { 13054684ddb6SLionel Sambuc size_type __words[__n_words]; 13064684ddb6SLionel Sambuc }; 13074684ddb6SLionel Sambuc 13084684ddb6SLionel Sambuc struct __rep 13094684ddb6SLionel Sambuc { 13104684ddb6SLionel Sambuc union 13114684ddb6SLionel Sambuc { 13124684ddb6SLionel Sambuc __long __l; 13134684ddb6SLionel Sambuc __short __s; 13144684ddb6SLionel Sambuc __raw __r; 13154684ddb6SLionel Sambuc }; 13164684ddb6SLionel Sambuc }; 13174684ddb6SLionel Sambuc 13184684ddb6SLionel Sambuc __compressed_pair<__rep, allocator_type> __r_; 13194684ddb6SLionel Sambuc 13204684ddb6SLionel Sambucpublic: 13214684ddb6SLionel Sambuc static const size_type npos = -1; 13224684ddb6SLionel Sambuc 13234684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY basic_string() 13244684ddb6SLionel Sambuc _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value); 1325*0a6a1f1dSLionel Sambuc 1326*0a6a1f1dSLionel Sambuc _LIBCPP_INLINE_VISIBILITY explicit basic_string(const allocator_type& __a) 1327*0a6a1f1dSLionel Sambuc#if _LIBCPP_STD_VER <= 14 1328*0a6a1f1dSLionel Sambuc _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value); 1329*0a6a1f1dSLionel Sambuc#else 1330*0a6a1f1dSLionel Sambuc _NOEXCEPT; 1331*0a6a1f1dSLionel Sambuc#endif 1332*0a6a1f1dSLionel Sambuc 13334684ddb6SLionel Sambuc basic_string(const basic_string& __str); 13344684ddb6SLionel Sambuc basic_string(const basic_string& __str, const allocator_type& __a); 1335*0a6a1f1dSLionel Sambuc 13364684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 13374684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 13384684ddb6SLionel Sambuc basic_string(basic_string&& __str) 1339*0a6a1f1dSLionel Sambuc#if _LIBCPP_STD_VER <= 14 13404684ddb6SLionel Sambuc _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value); 1341*0a6a1f1dSLionel Sambuc#else 1342*0a6a1f1dSLionel Sambuc _NOEXCEPT; 1343*0a6a1f1dSLionel Sambuc#endif 1344*0a6a1f1dSLionel Sambuc 13454684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 13464684ddb6SLionel Sambuc basic_string(basic_string&& __str, const allocator_type& __a); 13474684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 13484684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY basic_string(const value_type* __s); 13494684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 13504684ddb6SLionel Sambuc basic_string(const value_type* __s, const allocator_type& __a); 13514684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 13524684ddb6SLionel Sambuc basic_string(const value_type* __s, size_type __n); 13534684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 13544684ddb6SLionel Sambuc basic_string(const value_type* __s, size_type __n, const allocator_type& __a); 13554684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 13564684ddb6SLionel Sambuc basic_string(size_type __n, value_type __c); 13574684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 13584684ddb6SLionel Sambuc basic_string(size_type __n, value_type __c, const allocator_type& __a); 13594684ddb6SLionel Sambuc basic_string(const basic_string& __str, size_type __pos, size_type __n = npos, 13604684ddb6SLionel Sambuc const allocator_type& __a = allocator_type()); 13614684ddb6SLionel Sambuc template<class _InputIterator> 13624684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 13634684ddb6SLionel Sambuc basic_string(_InputIterator __first, _InputIterator __last); 13644684ddb6SLionel Sambuc template<class _InputIterator> 13654684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 13664684ddb6SLionel Sambuc basic_string(_InputIterator __first, _InputIterator __last, const allocator_type& __a); 13674684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 13684684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 13694684ddb6SLionel Sambuc basic_string(initializer_list<value_type> __il); 13704684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 13714684ddb6SLionel Sambuc basic_string(initializer_list<value_type> __il, const allocator_type& __a); 13724684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 13734684ddb6SLionel Sambuc 13744684ddb6SLionel Sambuc ~basic_string(); 13754684ddb6SLionel Sambuc 13764684ddb6SLionel Sambuc basic_string& operator=(const basic_string& __str); 13774684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 13784684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 13794684ddb6SLionel Sambuc basic_string& operator=(basic_string&& __str) 1380*0a6a1f1dSLionel Sambuc _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)); 13814684ddb6SLionel Sambuc#endif 13824684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY basic_string& operator=(const value_type* __s) {return assign(__s);} 13834684ddb6SLionel Sambuc basic_string& operator=(value_type __c); 13844684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 13854684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 13864684ddb6SLionel Sambuc basic_string& operator=(initializer_list<value_type> __il) {return assign(__il.begin(), __il.size());} 13874684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 13884684ddb6SLionel Sambuc 13894684ddb6SLionel Sambuc#if _LIBCPP_DEBUG_LEVEL >= 2 13904684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 13914684ddb6SLionel Sambuc iterator begin() _NOEXCEPT 13924684ddb6SLionel Sambuc {return iterator(this, __get_pointer());} 13934684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 13944684ddb6SLionel Sambuc const_iterator begin() const _NOEXCEPT 13954684ddb6SLionel Sambuc {return const_iterator(this, __get_pointer());} 13964684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 13974684ddb6SLionel Sambuc iterator end() _NOEXCEPT 13984684ddb6SLionel Sambuc {return iterator(this, __get_pointer() + size());} 13994684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 14004684ddb6SLionel Sambuc const_iterator end() const _NOEXCEPT 14014684ddb6SLionel Sambuc {return const_iterator(this, __get_pointer() + size());} 14024684ddb6SLionel Sambuc#else 14034684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 14044684ddb6SLionel Sambuc iterator begin() _NOEXCEPT 14054684ddb6SLionel Sambuc {return iterator(__get_pointer());} 14064684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 14074684ddb6SLionel Sambuc const_iterator begin() const _NOEXCEPT 14084684ddb6SLionel Sambuc {return const_iterator(__get_pointer());} 14094684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 14104684ddb6SLionel Sambuc iterator end() _NOEXCEPT 14114684ddb6SLionel Sambuc {return iterator(__get_pointer() + size());} 14124684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 14134684ddb6SLionel Sambuc const_iterator end() const _NOEXCEPT 14144684ddb6SLionel Sambuc {return const_iterator(__get_pointer() + size());} 14154684ddb6SLionel Sambuc#endif // _LIBCPP_DEBUG_LEVEL >= 2 14164684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 14174684ddb6SLionel Sambuc reverse_iterator rbegin() _NOEXCEPT 14184684ddb6SLionel Sambuc {return reverse_iterator(end());} 14194684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 14204684ddb6SLionel Sambuc const_reverse_iterator rbegin() const _NOEXCEPT 14214684ddb6SLionel Sambuc {return const_reverse_iterator(end());} 14224684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 14234684ddb6SLionel Sambuc reverse_iterator rend() _NOEXCEPT 14244684ddb6SLionel Sambuc {return reverse_iterator(begin());} 14254684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 14264684ddb6SLionel Sambuc const_reverse_iterator rend() const _NOEXCEPT 14274684ddb6SLionel Sambuc {return const_reverse_iterator(begin());} 14284684ddb6SLionel Sambuc 14294684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 14304684ddb6SLionel Sambuc const_iterator cbegin() const _NOEXCEPT 14314684ddb6SLionel Sambuc {return begin();} 14324684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 14334684ddb6SLionel Sambuc const_iterator cend() const _NOEXCEPT 14344684ddb6SLionel Sambuc {return end();} 14354684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 14364684ddb6SLionel Sambuc const_reverse_iterator crbegin() const _NOEXCEPT 14374684ddb6SLionel Sambuc {return rbegin();} 14384684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 14394684ddb6SLionel Sambuc const_reverse_iterator crend() const _NOEXCEPT 14404684ddb6SLionel Sambuc {return rend();} 14414684ddb6SLionel Sambuc 14424684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY size_type size() const _NOEXCEPT 14434684ddb6SLionel Sambuc {return __is_long() ? __get_long_size() : __get_short_size();} 14444684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY size_type length() const _NOEXCEPT {return size();} 14454684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT; 14464684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY size_type capacity() const _NOEXCEPT 14474684ddb6SLionel Sambuc {return (__is_long() ? __get_long_cap() : __min_cap) - 1;} 14484684ddb6SLionel Sambuc 14494684ddb6SLionel Sambuc void resize(size_type __n, value_type __c); 14504684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY void resize(size_type __n) {resize(__n, value_type());} 14514684ddb6SLionel Sambuc 14524684ddb6SLionel Sambuc void reserve(size_type res_arg = 0); 14534684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 14544684ddb6SLionel Sambuc void shrink_to_fit() _NOEXCEPT {reserve();} 14554684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 14564684ddb6SLionel Sambuc void clear() _NOEXCEPT; 14574684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY bool empty() const _NOEXCEPT {return size() == 0;} 14584684ddb6SLionel Sambuc 14594684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __pos) const; 14604684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __pos); 14614684ddb6SLionel Sambuc 14624684ddb6SLionel Sambuc const_reference at(size_type __n) const; 14634684ddb6SLionel Sambuc reference at(size_type __n); 14644684ddb6SLionel Sambuc 14654684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(const basic_string& __str) {return append(__str);} 14664684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(const value_type* __s) {return append(__s);} 14674684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(value_type __c) {push_back(__c); return *this;} 14684684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 14694684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(initializer_list<value_type> __il) {return append(__il);} 14704684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 14714684ddb6SLionel Sambuc 14724684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 14734684ddb6SLionel Sambuc basic_string& append(const basic_string& __str); 1474*0a6a1f1dSLionel Sambuc basic_string& append(const basic_string& __str, size_type __pos, size_type __n=npos); 14754684ddb6SLionel Sambuc basic_string& append(const value_type* __s, size_type __n); 14764684ddb6SLionel Sambuc basic_string& append(const value_type* __s); 14774684ddb6SLionel Sambuc basic_string& append(size_type __n, value_type __c); 14784684ddb6SLionel Sambuc template<class _InputIterator> 14794684ddb6SLionel Sambuc typename enable_if 14804684ddb6SLionel Sambuc < 14814684ddb6SLionel Sambuc __is_input_iterator <_InputIterator>::value && 14824684ddb6SLionel Sambuc !__is_forward_iterator<_InputIterator>::value, 14834684ddb6SLionel Sambuc basic_string& 14844684ddb6SLionel Sambuc >::type 14854684ddb6SLionel Sambuc append(_InputIterator __first, _InputIterator __last); 14864684ddb6SLionel Sambuc template<class _ForwardIterator> 14874684ddb6SLionel Sambuc typename enable_if 14884684ddb6SLionel Sambuc < 14894684ddb6SLionel Sambuc __is_forward_iterator<_ForwardIterator>::value, 14904684ddb6SLionel Sambuc basic_string& 14914684ddb6SLionel Sambuc >::type 14924684ddb6SLionel Sambuc append(_ForwardIterator __first, _ForwardIterator __last); 14934684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 14944684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 14954684ddb6SLionel Sambuc basic_string& append(initializer_list<value_type> __il) {return append(__il.begin(), __il.size());} 14964684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 14974684ddb6SLionel Sambuc 14984684ddb6SLionel Sambuc void push_back(value_type __c); 14994684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 15004684ddb6SLionel Sambuc void pop_back(); 15014684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY reference front(); 15024684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY const_reference front() const; 15034684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY reference back(); 15044684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY const_reference back() const; 15054684ddb6SLionel Sambuc 15064684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 15074684ddb6SLionel Sambuc basic_string& assign(const basic_string& __str); 15084684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 15094684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 15104684ddb6SLionel Sambuc basic_string& assign(basic_string&& str) 15114684ddb6SLionel Sambuc {*this = _VSTD::move(str); return *this;} 15124684ddb6SLionel Sambuc#endif 1513*0a6a1f1dSLionel Sambuc basic_string& assign(const basic_string& __str, size_type __pos, size_type __n=npos); 15144684ddb6SLionel Sambuc basic_string& assign(const value_type* __s, size_type __n); 15154684ddb6SLionel Sambuc basic_string& assign(const value_type* __s); 15164684ddb6SLionel Sambuc basic_string& assign(size_type __n, value_type __c); 15174684ddb6SLionel Sambuc template<class _InputIterator> 15184684ddb6SLionel Sambuc typename enable_if 15194684ddb6SLionel Sambuc < 15204684ddb6SLionel Sambuc __is_input_iterator <_InputIterator>::value && 15214684ddb6SLionel Sambuc !__is_forward_iterator<_InputIterator>::value, 15224684ddb6SLionel Sambuc basic_string& 15234684ddb6SLionel Sambuc >::type 15244684ddb6SLionel Sambuc assign(_InputIterator __first, _InputIterator __last); 15254684ddb6SLionel Sambuc template<class _ForwardIterator> 15264684ddb6SLionel Sambuc typename enable_if 15274684ddb6SLionel Sambuc < 15284684ddb6SLionel Sambuc __is_forward_iterator<_ForwardIterator>::value, 15294684ddb6SLionel Sambuc basic_string& 15304684ddb6SLionel Sambuc >::type 15314684ddb6SLionel Sambuc assign(_ForwardIterator __first, _ForwardIterator __last); 15324684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 15334684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 15344684ddb6SLionel Sambuc basic_string& assign(initializer_list<value_type> __il) {return assign(__il.begin(), __il.size());} 15354684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 15364684ddb6SLionel Sambuc 15374684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 15384684ddb6SLionel Sambuc basic_string& insert(size_type __pos1, const basic_string& __str); 1539*0a6a1f1dSLionel Sambuc basic_string& insert(size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n=npos); 15404684ddb6SLionel Sambuc basic_string& insert(size_type __pos, const value_type* __s, size_type __n); 15414684ddb6SLionel Sambuc basic_string& insert(size_type __pos, const value_type* __s); 15424684ddb6SLionel Sambuc basic_string& insert(size_type __pos, size_type __n, value_type __c); 15434684ddb6SLionel Sambuc iterator insert(const_iterator __pos, value_type __c); 15444684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 15454684ddb6SLionel Sambuc iterator insert(const_iterator __pos, size_type __n, value_type __c); 15464684ddb6SLionel Sambuc template<class _InputIterator> 15474684ddb6SLionel Sambuc typename enable_if 15484684ddb6SLionel Sambuc < 15494684ddb6SLionel Sambuc __is_input_iterator <_InputIterator>::value && 15504684ddb6SLionel Sambuc !__is_forward_iterator<_InputIterator>::value, 15514684ddb6SLionel Sambuc iterator 15524684ddb6SLionel Sambuc >::type 15534684ddb6SLionel Sambuc insert(const_iterator __pos, _InputIterator __first, _InputIterator __last); 15544684ddb6SLionel Sambuc template<class _ForwardIterator> 15554684ddb6SLionel Sambuc typename enable_if 15564684ddb6SLionel Sambuc < 15574684ddb6SLionel Sambuc __is_forward_iterator<_ForwardIterator>::value, 15584684ddb6SLionel Sambuc iterator 15594684ddb6SLionel Sambuc >::type 15604684ddb6SLionel Sambuc insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last); 15614684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 15624684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 15634684ddb6SLionel Sambuc iterator insert(const_iterator __pos, initializer_list<value_type> __il) 15644684ddb6SLionel Sambuc {return insert(__pos, __il.begin(), __il.end());} 15654684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 15664684ddb6SLionel Sambuc 15674684ddb6SLionel Sambuc basic_string& erase(size_type __pos = 0, size_type __n = npos); 15684684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 15694684ddb6SLionel Sambuc iterator erase(const_iterator __pos); 15704684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 15714684ddb6SLionel Sambuc iterator erase(const_iterator __first, const_iterator __last); 15724684ddb6SLionel Sambuc 15734684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 15744684ddb6SLionel Sambuc basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str); 1575*0a6a1f1dSLionel Sambuc basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2=npos); 15764684ddb6SLionel Sambuc basic_string& replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2); 15774684ddb6SLionel Sambuc basic_string& replace(size_type __pos, size_type __n1, const value_type* __s); 15784684ddb6SLionel Sambuc basic_string& replace(size_type __pos, size_type __n1, size_type __n2, value_type __c); 15794684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 15804684ddb6SLionel Sambuc basic_string& replace(const_iterator __i1, const_iterator __i2, const basic_string& __str); 15814684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 15824684ddb6SLionel Sambuc basic_string& replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n); 15834684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 15844684ddb6SLionel Sambuc basic_string& replace(const_iterator __i1, const_iterator __i2, const value_type* __s); 15854684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 15864684ddb6SLionel Sambuc basic_string& replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c); 15874684ddb6SLionel Sambuc template<class _InputIterator> 15884684ddb6SLionel Sambuc typename enable_if 15894684ddb6SLionel Sambuc < 15904684ddb6SLionel Sambuc __is_input_iterator<_InputIterator>::value, 15914684ddb6SLionel Sambuc basic_string& 15924684ddb6SLionel Sambuc >::type 15934684ddb6SLionel Sambuc replace(const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2); 15944684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 15954684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 15964684ddb6SLionel Sambuc basic_string& replace(const_iterator __i1, const_iterator __i2, initializer_list<value_type> __il) 15974684ddb6SLionel Sambuc {return replace(__i1, __i2, __il.begin(), __il.end());} 15984684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 15994684ddb6SLionel Sambuc 16004684ddb6SLionel Sambuc size_type copy(value_type* __s, size_type __n, size_type __pos = 0) const; 16014684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16024684ddb6SLionel Sambuc basic_string substr(size_type __pos = 0, size_type __n = npos) const; 16034684ddb6SLionel Sambuc 16044684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16054684ddb6SLionel Sambuc void swap(basic_string& __str) 1606*0a6a1f1dSLionel Sambuc#if _LIBCPP_STD_VER >= 14 1607*0a6a1f1dSLionel Sambuc _NOEXCEPT; 1608*0a6a1f1dSLionel Sambuc#else 16094684ddb6SLionel Sambuc _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || 16104684ddb6SLionel Sambuc __is_nothrow_swappable<allocator_type>::value); 1611*0a6a1f1dSLionel Sambuc#endif 16124684ddb6SLionel Sambuc 16134684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16144684ddb6SLionel Sambuc const value_type* c_str() const _NOEXCEPT {return data();} 16154684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16164684ddb6SLionel Sambuc const value_type* data() const _NOEXCEPT {return _VSTD::__to_raw_pointer(__get_pointer());} 16174684ddb6SLionel Sambuc 16184684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16194684ddb6SLionel Sambuc allocator_type get_allocator() const _NOEXCEPT {return __alloc();} 16204684ddb6SLionel Sambuc 16214684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16224684ddb6SLionel Sambuc size_type find(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT; 16234684ddb6SLionel Sambuc size_type find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; 16244684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16254684ddb6SLionel Sambuc size_type find(const value_type* __s, size_type __pos = 0) const _NOEXCEPT; 16264684ddb6SLionel Sambuc size_type find(value_type __c, size_type __pos = 0) const _NOEXCEPT; 16274684ddb6SLionel Sambuc 16284684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16294684ddb6SLionel Sambuc size_type rfind(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT; 16304684ddb6SLionel Sambuc size_type rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; 16314684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16324684ddb6SLionel Sambuc size_type rfind(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; 16334684ddb6SLionel Sambuc size_type rfind(value_type __c, size_type __pos = npos) const _NOEXCEPT; 16344684ddb6SLionel Sambuc 16354684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16364684ddb6SLionel Sambuc size_type find_first_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT; 16374684ddb6SLionel Sambuc size_type find_first_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; 16384684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16394684ddb6SLionel Sambuc size_type find_first_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT; 16404684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16414684ddb6SLionel Sambuc size_type find_first_of(value_type __c, size_type __pos = 0) const _NOEXCEPT; 16424684ddb6SLionel Sambuc 16434684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16444684ddb6SLionel Sambuc size_type find_last_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT; 16454684ddb6SLionel Sambuc size_type find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; 16464684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16474684ddb6SLionel Sambuc size_type find_last_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; 16484684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16494684ddb6SLionel Sambuc size_type find_last_of(value_type __c, size_type __pos = npos) const _NOEXCEPT; 16504684ddb6SLionel Sambuc 16514684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16524684ddb6SLionel Sambuc size_type find_first_not_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT; 16534684ddb6SLionel Sambuc size_type find_first_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; 16544684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16554684ddb6SLionel Sambuc size_type find_first_not_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT; 16564684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16574684ddb6SLionel Sambuc size_type find_first_not_of(value_type __c, size_type __pos = 0) const _NOEXCEPT; 16584684ddb6SLionel Sambuc 16594684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16604684ddb6SLionel Sambuc size_type find_last_not_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT; 16614684ddb6SLionel Sambuc size_type find_last_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; 16624684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16634684ddb6SLionel Sambuc size_type find_last_not_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; 16644684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16654684ddb6SLionel Sambuc size_type find_last_not_of(value_type __c, size_type __pos = npos) const _NOEXCEPT; 16664684ddb6SLionel Sambuc 16674684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16684684ddb6SLionel Sambuc int compare(const basic_string& __str) const _NOEXCEPT; 16694684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16704684ddb6SLionel Sambuc int compare(size_type __pos1, size_type __n1, const basic_string& __str) const; 1671*0a6a1f1dSLionel Sambuc int compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2=npos) const; 16724684ddb6SLionel Sambuc int compare(const value_type* __s) const _NOEXCEPT; 16734684ddb6SLionel Sambuc int compare(size_type __pos1, size_type __n1, const value_type* __s) const; 16744684ddb6SLionel Sambuc int compare(size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const; 16754684ddb6SLionel Sambuc 16764684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY bool __invariants() const; 16774684ddb6SLionel Sambuc 16784684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16794684ddb6SLionel Sambuc bool __is_long() const _NOEXCEPT 16804684ddb6SLionel Sambuc {return bool(__r_.first().__s.__size_ & __short_mask);} 16814684ddb6SLionel Sambuc 16824684ddb6SLionel Sambuc#if _LIBCPP_DEBUG_LEVEL >= 2 16834684ddb6SLionel Sambuc 16844684ddb6SLionel Sambuc bool __dereferenceable(const const_iterator* __i) const; 16854684ddb6SLionel Sambuc bool __decrementable(const const_iterator* __i) const; 16864684ddb6SLionel Sambuc bool __addable(const const_iterator* __i, ptrdiff_t __n) const; 16874684ddb6SLionel Sambuc bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const; 16884684ddb6SLionel Sambuc 16894684ddb6SLionel Sambuc#endif // _LIBCPP_DEBUG_LEVEL >= 2 16904684ddb6SLionel Sambuc 16914684ddb6SLionel Sambucprivate: 16924684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16934684ddb6SLionel Sambuc allocator_type& __alloc() _NOEXCEPT 16944684ddb6SLionel Sambuc {return __r_.second();} 16954684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 16964684ddb6SLionel Sambuc const allocator_type& __alloc() const _NOEXCEPT 16974684ddb6SLionel Sambuc {return __r_.second();} 16984684ddb6SLionel Sambuc 16994684ddb6SLionel Sambuc#ifdef _LIBCPP_ALTERNATE_STRING_LAYOUT 17004684ddb6SLionel Sambuc 17014684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 17024684ddb6SLionel Sambuc void __set_short_size(size_type __s) _NOEXCEPT 17034684ddb6SLionel Sambuc# if _LIBCPP_BIG_ENDIAN 17044684ddb6SLionel Sambuc {__r_.first().__s.__size_ = (unsigned char)(__s << 1);} 17054684ddb6SLionel Sambuc# else 17064684ddb6SLionel Sambuc {__r_.first().__s.__size_ = (unsigned char)(__s);} 17074684ddb6SLionel Sambuc# endif 17084684ddb6SLionel Sambuc 17094684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 17104684ddb6SLionel Sambuc size_type __get_short_size() const _NOEXCEPT 17114684ddb6SLionel Sambuc# if _LIBCPP_BIG_ENDIAN 17124684ddb6SLionel Sambuc {return __r_.first().__s.__size_ >> 1;} 17134684ddb6SLionel Sambuc# else 17144684ddb6SLionel Sambuc {return __r_.first().__s.__size_;} 17154684ddb6SLionel Sambuc# endif 17164684ddb6SLionel Sambuc 17174684ddb6SLionel Sambuc#else // _LIBCPP_ALTERNATE_STRING_LAYOUT 17184684ddb6SLionel Sambuc 17194684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 17204684ddb6SLionel Sambuc void __set_short_size(size_type __s) _NOEXCEPT 17214684ddb6SLionel Sambuc# if _LIBCPP_BIG_ENDIAN 17224684ddb6SLionel Sambuc {__r_.first().__s.__size_ = (unsigned char)(__s);} 17234684ddb6SLionel Sambuc# else 17244684ddb6SLionel Sambuc {__r_.first().__s.__size_ = (unsigned char)(__s << 1);} 17254684ddb6SLionel Sambuc# endif 17264684ddb6SLionel Sambuc 17274684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 17284684ddb6SLionel Sambuc size_type __get_short_size() const _NOEXCEPT 17294684ddb6SLionel Sambuc# if _LIBCPP_BIG_ENDIAN 17304684ddb6SLionel Sambuc {return __r_.first().__s.__size_;} 17314684ddb6SLionel Sambuc# else 17324684ddb6SLionel Sambuc {return __r_.first().__s.__size_ >> 1;} 17334684ddb6SLionel Sambuc# endif 17344684ddb6SLionel Sambuc 17354684ddb6SLionel Sambuc#endif // _LIBCPP_ALTERNATE_STRING_LAYOUT 17364684ddb6SLionel Sambuc 17374684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 17384684ddb6SLionel Sambuc void __set_long_size(size_type __s) _NOEXCEPT 17394684ddb6SLionel Sambuc {__r_.first().__l.__size_ = __s;} 17404684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 17414684ddb6SLionel Sambuc size_type __get_long_size() const _NOEXCEPT 17424684ddb6SLionel Sambuc {return __r_.first().__l.__size_;} 17434684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 17444684ddb6SLionel Sambuc void __set_size(size_type __s) _NOEXCEPT 17454684ddb6SLionel Sambuc {if (__is_long()) __set_long_size(__s); else __set_short_size(__s);} 17464684ddb6SLionel Sambuc 17474684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 17484684ddb6SLionel Sambuc void __set_long_cap(size_type __s) _NOEXCEPT 17494684ddb6SLionel Sambuc {__r_.first().__l.__cap_ = __long_mask | __s;} 17504684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 17514684ddb6SLionel Sambuc size_type __get_long_cap() const _NOEXCEPT 17524684ddb6SLionel Sambuc {return __r_.first().__l.__cap_ & size_type(~__long_mask);} 17534684ddb6SLionel Sambuc 17544684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 17554684ddb6SLionel Sambuc void __set_long_pointer(pointer __p) _NOEXCEPT 17564684ddb6SLionel Sambuc {__r_.first().__l.__data_ = __p;} 17574684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 17584684ddb6SLionel Sambuc pointer __get_long_pointer() _NOEXCEPT 17594684ddb6SLionel Sambuc {return __r_.first().__l.__data_;} 17604684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 17614684ddb6SLionel Sambuc const_pointer __get_long_pointer() const _NOEXCEPT 17624684ddb6SLionel Sambuc {return __r_.first().__l.__data_;} 17634684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 17644684ddb6SLionel Sambuc pointer __get_short_pointer() _NOEXCEPT 17654684ddb6SLionel Sambuc {return pointer_traits<pointer>::pointer_to(__r_.first().__s.__data_[0]);} 17664684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 17674684ddb6SLionel Sambuc const_pointer __get_short_pointer() const _NOEXCEPT 17684684ddb6SLionel Sambuc {return pointer_traits<const_pointer>::pointer_to(__r_.first().__s.__data_[0]);} 17694684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 17704684ddb6SLionel Sambuc pointer __get_pointer() _NOEXCEPT 17714684ddb6SLionel Sambuc {return __is_long() ? __get_long_pointer() : __get_short_pointer();} 17724684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 17734684ddb6SLionel Sambuc const_pointer __get_pointer() const _NOEXCEPT 17744684ddb6SLionel Sambuc {return __is_long() ? __get_long_pointer() : __get_short_pointer();} 17754684ddb6SLionel Sambuc 17764684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 17774684ddb6SLionel Sambuc void __zero() _NOEXCEPT 17784684ddb6SLionel Sambuc { 17794684ddb6SLionel Sambuc size_type (&__a)[__n_words] = __r_.first().__r.__words; 17804684ddb6SLionel Sambuc for (unsigned __i = 0; __i < __n_words; ++__i) 17814684ddb6SLionel Sambuc __a[__i] = 0; 17824684ddb6SLionel Sambuc } 17834684ddb6SLionel Sambuc 17844684ddb6SLionel Sambuc template <size_type __a> static 17854684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 17864684ddb6SLionel Sambuc size_type __align_it(size_type __s) _NOEXCEPT 17874684ddb6SLionel Sambuc {return __s + (__a-1) & ~(__a-1);} 17884684ddb6SLionel Sambuc enum {__alignment = 16}; 17894684ddb6SLionel Sambuc static _LIBCPP_INLINE_VISIBILITY 17904684ddb6SLionel Sambuc size_type __recommend(size_type __s) _NOEXCEPT 17914684ddb6SLionel Sambuc {return (__s < __min_cap ? __min_cap : 17924684ddb6SLionel Sambuc __align_it<sizeof(value_type) < __alignment ? 17934684ddb6SLionel Sambuc __alignment/sizeof(value_type) : 1 > (__s+1)) - 1;} 17944684ddb6SLionel Sambuc 17954684ddb6SLionel Sambuc void __init(const value_type* __s, size_type __sz, size_type __reserve); 17964684ddb6SLionel Sambuc void __init(const value_type* __s, size_type __sz); 17974684ddb6SLionel Sambuc void __init(size_type __n, value_type __c); 17984684ddb6SLionel Sambuc 17994684ddb6SLionel Sambuc template <class _InputIterator> 18004684ddb6SLionel Sambuc typename enable_if 18014684ddb6SLionel Sambuc < 18024684ddb6SLionel Sambuc __is_input_iterator <_InputIterator>::value && 18034684ddb6SLionel Sambuc !__is_forward_iterator<_InputIterator>::value, 18044684ddb6SLionel Sambuc void 18054684ddb6SLionel Sambuc >::type 18064684ddb6SLionel Sambuc __init(_InputIterator __first, _InputIterator __last); 18074684ddb6SLionel Sambuc 18084684ddb6SLionel Sambuc template <class _ForwardIterator> 18094684ddb6SLionel Sambuc typename enable_if 18104684ddb6SLionel Sambuc < 18114684ddb6SLionel Sambuc __is_forward_iterator<_ForwardIterator>::value, 18124684ddb6SLionel Sambuc void 18134684ddb6SLionel Sambuc >::type 18144684ddb6SLionel Sambuc __init(_ForwardIterator __first, _ForwardIterator __last); 18154684ddb6SLionel Sambuc 18164684ddb6SLionel Sambuc void __grow_by(size_type __old_cap, size_type __delta_cap, size_type __old_sz, 18174684ddb6SLionel Sambuc size_type __n_copy, size_type __n_del, size_type __n_add = 0); 18184684ddb6SLionel Sambuc void __grow_by_and_replace(size_type __old_cap, size_type __delta_cap, size_type __old_sz, 18194684ddb6SLionel Sambuc size_type __n_copy, size_type __n_del, 18204684ddb6SLionel Sambuc size_type __n_add, const value_type* __p_new_stuff); 18214684ddb6SLionel Sambuc 18224684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 18234684ddb6SLionel Sambuc void __erase_to_end(size_type __pos); 18244684ddb6SLionel Sambuc 18254684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 18264684ddb6SLionel Sambuc void __copy_assign_alloc(const basic_string& __str) 18274684ddb6SLionel Sambuc {__copy_assign_alloc(__str, integral_constant<bool, 18284684ddb6SLionel Sambuc __alloc_traits::propagate_on_container_copy_assignment::value>());} 18294684ddb6SLionel Sambuc 18304684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 18314684ddb6SLionel Sambuc void __copy_assign_alloc(const basic_string& __str, true_type) 18324684ddb6SLionel Sambuc { 18334684ddb6SLionel Sambuc if (__alloc() != __str.__alloc()) 18344684ddb6SLionel Sambuc { 18354684ddb6SLionel Sambuc clear(); 18364684ddb6SLionel Sambuc shrink_to_fit(); 18374684ddb6SLionel Sambuc } 18384684ddb6SLionel Sambuc __alloc() = __str.__alloc(); 18394684ddb6SLionel Sambuc } 18404684ddb6SLionel Sambuc 18414684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 18424684ddb6SLionel Sambuc void __copy_assign_alloc(const basic_string&, false_type) _NOEXCEPT 18434684ddb6SLionel Sambuc {} 18444684ddb6SLionel Sambuc 18454684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 18464684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 1847*0a6a1f1dSLionel Sambuc void __move_assign(basic_string& __str, false_type) 1848*0a6a1f1dSLionel Sambuc _NOEXCEPT_(__alloc_traits::is_always_equal::value); 18494684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 18504684ddb6SLionel Sambuc void __move_assign(basic_string& __str, true_type) 1851*0a6a1f1dSLionel Sambuc#if _LIBCPP_STD_VER > 14 1852*0a6a1f1dSLionel Sambuc _NOEXCEPT; 1853*0a6a1f1dSLionel Sambuc#else 18544684ddb6SLionel Sambuc _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value); 18554684ddb6SLionel Sambuc#endif 1856*0a6a1f1dSLionel Sambuc#endif 18574684ddb6SLionel Sambuc 18584684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 18594684ddb6SLionel Sambuc void 18604684ddb6SLionel Sambuc __move_assign_alloc(basic_string& __str) 18614684ddb6SLionel Sambuc _NOEXCEPT_( 18624684ddb6SLionel Sambuc !__alloc_traits::propagate_on_container_move_assignment::value || 18634684ddb6SLionel Sambuc is_nothrow_move_assignable<allocator_type>::value) 18644684ddb6SLionel Sambuc {__move_assign_alloc(__str, integral_constant<bool, 18654684ddb6SLionel Sambuc __alloc_traits::propagate_on_container_move_assignment::value>());} 18664684ddb6SLionel Sambuc 18674684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 18684684ddb6SLionel Sambuc void __move_assign_alloc(basic_string& __c, true_type) 18694684ddb6SLionel Sambuc _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) 18704684ddb6SLionel Sambuc { 18714684ddb6SLionel Sambuc __alloc() = _VSTD::move(__c.__alloc()); 18724684ddb6SLionel Sambuc } 18734684ddb6SLionel Sambuc 18744684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 18754684ddb6SLionel Sambuc void __move_assign_alloc(basic_string&, false_type) 18764684ddb6SLionel Sambuc _NOEXCEPT 18774684ddb6SLionel Sambuc {} 18784684ddb6SLionel Sambuc 18794684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators(); 18804684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(size_type); 18814684ddb6SLionel Sambuc 18824684ddb6SLionel Sambuc friend basic_string operator+<>(const basic_string&, const basic_string&); 18834684ddb6SLionel Sambuc friend basic_string operator+<>(const value_type*, const basic_string&); 18844684ddb6SLionel Sambuc friend basic_string operator+<>(value_type, const basic_string&); 18854684ddb6SLionel Sambuc friend basic_string operator+<>(const basic_string&, const value_type*); 18864684ddb6SLionel Sambuc friend basic_string operator+<>(const basic_string&, value_type); 18874684ddb6SLionel Sambuc}; 18884684ddb6SLionel Sambuc 18894684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 18904684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 18914684ddb6SLionel Sambucvoid 18924684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::__invalidate_all_iterators() 18934684ddb6SLionel Sambuc{ 18944684ddb6SLionel Sambuc#if _LIBCPP_DEBUG_LEVEL >= 2 18954684ddb6SLionel Sambuc __get_db()->__invalidate_all(this); 18964684ddb6SLionel Sambuc#endif // _LIBCPP_DEBUG_LEVEL >= 2 18974684ddb6SLionel Sambuc} 18984684ddb6SLionel Sambuc 18994684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 19004684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 19014684ddb6SLionel Sambucvoid 19024684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type 19034684ddb6SLionel Sambuc#if _LIBCPP_DEBUG_LEVEL >= 2 19044684ddb6SLionel Sambuc __pos 19054684ddb6SLionel Sambuc#endif 19064684ddb6SLionel Sambuc ) 19074684ddb6SLionel Sambuc{ 19084684ddb6SLionel Sambuc#if _LIBCPP_DEBUG_LEVEL >= 2 19094684ddb6SLionel Sambuc __c_node* __c = __get_db()->__find_c_and_lock(this); 19104684ddb6SLionel Sambuc if (__c) 19114684ddb6SLionel Sambuc { 19124684ddb6SLionel Sambuc const_pointer __new_last = __get_pointer() + __pos; 19134684ddb6SLionel Sambuc for (__i_node** __p = __c->end_; __p != __c->beg_; ) 19144684ddb6SLionel Sambuc { 19154684ddb6SLionel Sambuc --__p; 19164684ddb6SLionel Sambuc const_iterator* __i = static_cast<const_iterator*>((*__p)->__i_); 19174684ddb6SLionel Sambuc if (__i->base() > __new_last) 19184684ddb6SLionel Sambuc { 19194684ddb6SLionel Sambuc (*__p)->__c_ = nullptr; 19204684ddb6SLionel Sambuc if (--__c->end_ != __p) 19214684ddb6SLionel Sambuc memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*)); 19224684ddb6SLionel Sambuc } 19234684ddb6SLionel Sambuc } 19244684ddb6SLionel Sambuc __get_db()->unlock(); 19254684ddb6SLionel Sambuc } 19264684ddb6SLionel Sambuc#endif // _LIBCPP_DEBUG_LEVEL >= 2 19274684ddb6SLionel Sambuc} 19284684ddb6SLionel Sambuc 19294684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 19304684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 19314684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::basic_string() 19324684ddb6SLionel Sambuc _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) 19334684ddb6SLionel Sambuc{ 19344684ddb6SLionel Sambuc#if _LIBCPP_DEBUG_LEVEL >= 2 19354684ddb6SLionel Sambuc __get_db()->__insert_c(this); 19364684ddb6SLionel Sambuc#endif 19374684ddb6SLionel Sambuc __zero(); 19384684ddb6SLionel Sambuc} 19394684ddb6SLionel Sambuc 19404684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 19414684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 19424684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::basic_string(const allocator_type& __a) 1943*0a6a1f1dSLionel Sambuc#if _LIBCPP_STD_VER <= 14 1944*0a6a1f1dSLionel Sambuc _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value) 1945*0a6a1f1dSLionel Sambuc#else 1946*0a6a1f1dSLionel Sambuc _NOEXCEPT 1947*0a6a1f1dSLionel Sambuc#endif 19484684ddb6SLionel Sambuc: __r_(__a) 19494684ddb6SLionel Sambuc{ 19504684ddb6SLionel Sambuc#if _LIBCPP_DEBUG_LEVEL >= 2 19514684ddb6SLionel Sambuc __get_db()->__insert_c(this); 19524684ddb6SLionel Sambuc#endif 19534684ddb6SLionel Sambuc __zero(); 19544684ddb6SLionel Sambuc} 19554684ddb6SLionel Sambuc 19564684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 19574684ddb6SLionel Sambucvoid 19584684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz, size_type __reserve) 19594684ddb6SLionel Sambuc{ 19604684ddb6SLionel Sambuc if (__reserve > max_size()) 19614684ddb6SLionel Sambuc this->__throw_length_error(); 19624684ddb6SLionel Sambuc pointer __p; 19634684ddb6SLionel Sambuc if (__reserve < __min_cap) 19644684ddb6SLionel Sambuc { 19654684ddb6SLionel Sambuc __set_short_size(__sz); 19664684ddb6SLionel Sambuc __p = __get_short_pointer(); 19674684ddb6SLionel Sambuc } 19684684ddb6SLionel Sambuc else 19694684ddb6SLionel Sambuc { 19704684ddb6SLionel Sambuc size_type __cap = __recommend(__reserve); 19714684ddb6SLionel Sambuc __p = __alloc_traits::allocate(__alloc(), __cap+1); 19724684ddb6SLionel Sambuc __set_long_pointer(__p); 19734684ddb6SLionel Sambuc __set_long_cap(__cap+1); 19744684ddb6SLionel Sambuc __set_long_size(__sz); 19754684ddb6SLionel Sambuc } 19764684ddb6SLionel Sambuc traits_type::copy(_VSTD::__to_raw_pointer(__p), __s, __sz); 19774684ddb6SLionel Sambuc traits_type::assign(__p[__sz], value_type()); 19784684ddb6SLionel Sambuc} 19794684ddb6SLionel Sambuc 19804684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 19814684ddb6SLionel Sambucvoid 19824684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz) 19834684ddb6SLionel Sambuc{ 19844684ddb6SLionel Sambuc if (__sz > max_size()) 19854684ddb6SLionel Sambuc this->__throw_length_error(); 19864684ddb6SLionel Sambuc pointer __p; 19874684ddb6SLionel Sambuc if (__sz < __min_cap) 19884684ddb6SLionel Sambuc { 19894684ddb6SLionel Sambuc __set_short_size(__sz); 19904684ddb6SLionel Sambuc __p = __get_short_pointer(); 19914684ddb6SLionel Sambuc } 19924684ddb6SLionel Sambuc else 19934684ddb6SLionel Sambuc { 19944684ddb6SLionel Sambuc size_type __cap = __recommend(__sz); 19954684ddb6SLionel Sambuc __p = __alloc_traits::allocate(__alloc(), __cap+1); 19964684ddb6SLionel Sambuc __set_long_pointer(__p); 19974684ddb6SLionel Sambuc __set_long_cap(__cap+1); 19984684ddb6SLionel Sambuc __set_long_size(__sz); 19994684ddb6SLionel Sambuc } 20004684ddb6SLionel Sambuc traits_type::copy(_VSTD::__to_raw_pointer(__p), __s, __sz); 20014684ddb6SLionel Sambuc traits_type::assign(__p[__sz], value_type()); 20024684ddb6SLionel Sambuc} 20034684ddb6SLionel Sambuc 20044684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 20054684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 20064684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::basic_string(const value_type* __s) 20074684ddb6SLionel Sambuc{ 20084684ddb6SLionel Sambuc _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*) detected nullptr"); 20094684ddb6SLionel Sambuc __init(__s, traits_type::length(__s)); 20104684ddb6SLionel Sambuc#if _LIBCPP_DEBUG_LEVEL >= 2 20114684ddb6SLionel Sambuc __get_db()->__insert_c(this); 20124684ddb6SLionel Sambuc#endif 20134684ddb6SLionel Sambuc} 20144684ddb6SLionel Sambuc 20154684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 20164684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 20174684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::basic_string(const value_type* __s, const allocator_type& __a) 20184684ddb6SLionel Sambuc : __r_(__a) 20194684ddb6SLionel Sambuc{ 20204684ddb6SLionel Sambuc _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*, allocator) detected nullptr"); 20214684ddb6SLionel Sambuc __init(__s, traits_type::length(__s)); 20224684ddb6SLionel Sambuc#if _LIBCPP_DEBUG_LEVEL >= 2 20234684ddb6SLionel Sambuc __get_db()->__insert_c(this); 20244684ddb6SLionel Sambuc#endif 20254684ddb6SLionel Sambuc} 20264684ddb6SLionel Sambuc 20274684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 20284684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 20294684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::basic_string(const value_type* __s, size_type __n) 20304684ddb6SLionel Sambuc{ 20314684ddb6SLionel Sambuc _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n) detected nullptr"); 20324684ddb6SLionel Sambuc __init(__s, __n); 20334684ddb6SLionel Sambuc#if _LIBCPP_DEBUG_LEVEL >= 2 20344684ddb6SLionel Sambuc __get_db()->__insert_c(this); 20354684ddb6SLionel Sambuc#endif 20364684ddb6SLionel Sambuc} 20374684ddb6SLionel Sambuc 20384684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 20394684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 20404684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::basic_string(const value_type* __s, size_type __n, const allocator_type& __a) 20414684ddb6SLionel Sambuc : __r_(__a) 20424684ddb6SLionel Sambuc{ 20434684ddb6SLionel Sambuc _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr"); 20444684ddb6SLionel Sambuc __init(__s, __n); 20454684ddb6SLionel Sambuc#if _LIBCPP_DEBUG_LEVEL >= 2 20464684ddb6SLionel Sambuc __get_db()->__insert_c(this); 20474684ddb6SLionel Sambuc#endif 20484684ddb6SLionel Sambuc} 20494684ddb6SLionel Sambuc 20504684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 20514684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str) 20524684ddb6SLionel Sambuc : __r_(__alloc_traits::select_on_container_copy_construction(__str.__alloc())) 20534684ddb6SLionel Sambuc{ 20544684ddb6SLionel Sambuc if (!__str.__is_long()) 20554684ddb6SLionel Sambuc __r_.first().__r = __str.__r_.first().__r; 20564684ddb6SLionel Sambuc else 20574684ddb6SLionel Sambuc __init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size()); 20584684ddb6SLionel Sambuc#if _LIBCPP_DEBUG_LEVEL >= 2 20594684ddb6SLionel Sambuc __get_db()->__insert_c(this); 20604684ddb6SLionel Sambuc#endif 20614684ddb6SLionel Sambuc} 20624684ddb6SLionel Sambuc 20634684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 20644684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str, const allocator_type& __a) 20654684ddb6SLionel Sambuc : __r_(__a) 20664684ddb6SLionel Sambuc{ 20674684ddb6SLionel Sambuc if (!__str.__is_long()) 20684684ddb6SLionel Sambuc __r_.first().__r = __str.__r_.first().__r; 20694684ddb6SLionel Sambuc else 20704684ddb6SLionel Sambuc __init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size()); 20714684ddb6SLionel Sambuc#if _LIBCPP_DEBUG_LEVEL >= 2 20724684ddb6SLionel Sambuc __get_db()->__insert_c(this); 20734684ddb6SLionel Sambuc#endif 20744684ddb6SLionel Sambuc} 20754684ddb6SLionel Sambuc 20764684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 20774684ddb6SLionel Sambuc 20784684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 20794684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 20804684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str) 2081*0a6a1f1dSLionel Sambuc#if _LIBCPP_STD_VER <= 14 20824684ddb6SLionel Sambuc _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value) 2083*0a6a1f1dSLionel Sambuc#else 2084*0a6a1f1dSLionel Sambuc _NOEXCEPT 2085*0a6a1f1dSLionel Sambuc#endif 20864684ddb6SLionel Sambuc : __r_(_VSTD::move(__str.__r_)) 20874684ddb6SLionel Sambuc{ 20884684ddb6SLionel Sambuc __str.__zero(); 20894684ddb6SLionel Sambuc#if _LIBCPP_DEBUG_LEVEL >= 2 20904684ddb6SLionel Sambuc __get_db()->__insert_c(this); 20914684ddb6SLionel Sambuc if (__is_long()) 20924684ddb6SLionel Sambuc __get_db()->swap(this, &__str); 20934684ddb6SLionel Sambuc#endif 20944684ddb6SLionel Sambuc} 20954684ddb6SLionel Sambuc 20964684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 20974684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 20984684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str, const allocator_type& __a) 20994684ddb6SLionel Sambuc : __r_(__a) 21004684ddb6SLionel Sambuc{ 2101*0a6a1f1dSLionel Sambuc if (__str.__is_long() && __a != __str.__alloc()) // copy, not move 21024684ddb6SLionel Sambuc __init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size()); 2103*0a6a1f1dSLionel Sambuc else 2104*0a6a1f1dSLionel Sambuc { 2105*0a6a1f1dSLionel Sambuc __r_.first().__r = __str.__r_.first().__r; 21064684ddb6SLionel Sambuc __str.__zero(); 2107*0a6a1f1dSLionel Sambuc } 21084684ddb6SLionel Sambuc#if _LIBCPP_DEBUG_LEVEL >= 2 21094684ddb6SLionel Sambuc __get_db()->__insert_c(this); 21104684ddb6SLionel Sambuc if (__is_long()) 21114684ddb6SLionel Sambuc __get_db()->swap(this, &__str); 21124684ddb6SLionel Sambuc#endif 21134684ddb6SLionel Sambuc} 21144684ddb6SLionel Sambuc 21154684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 21164684ddb6SLionel Sambuc 21174684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 21184684ddb6SLionel Sambucvoid 21194684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c) 21204684ddb6SLionel Sambuc{ 21214684ddb6SLionel Sambuc if (__n > max_size()) 21224684ddb6SLionel Sambuc this->__throw_length_error(); 21234684ddb6SLionel Sambuc pointer __p; 21244684ddb6SLionel Sambuc if (__n < __min_cap) 21254684ddb6SLionel Sambuc { 21264684ddb6SLionel Sambuc __set_short_size(__n); 21274684ddb6SLionel Sambuc __p = __get_short_pointer(); 21284684ddb6SLionel Sambuc } 21294684ddb6SLionel Sambuc else 21304684ddb6SLionel Sambuc { 21314684ddb6SLionel Sambuc size_type __cap = __recommend(__n); 21324684ddb6SLionel Sambuc __p = __alloc_traits::allocate(__alloc(), __cap+1); 21334684ddb6SLionel Sambuc __set_long_pointer(__p); 21344684ddb6SLionel Sambuc __set_long_cap(__cap+1); 21354684ddb6SLionel Sambuc __set_long_size(__n); 21364684ddb6SLionel Sambuc } 21374684ddb6SLionel Sambuc traits_type::assign(_VSTD::__to_raw_pointer(__p), __n, __c); 21384684ddb6SLionel Sambuc traits_type::assign(__p[__n], value_type()); 21394684ddb6SLionel Sambuc} 21404684ddb6SLionel Sambuc 21414684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 21424684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 21434684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, value_type __c) 21444684ddb6SLionel Sambuc{ 21454684ddb6SLionel Sambuc __init(__n, __c); 21464684ddb6SLionel Sambuc#if _LIBCPP_DEBUG_LEVEL >= 2 21474684ddb6SLionel Sambuc __get_db()->__insert_c(this); 21484684ddb6SLionel Sambuc#endif 21494684ddb6SLionel Sambuc} 21504684ddb6SLionel Sambuc 21514684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 21524684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 21534684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, value_type __c, const allocator_type& __a) 21544684ddb6SLionel Sambuc : __r_(__a) 21554684ddb6SLionel Sambuc{ 21564684ddb6SLionel Sambuc __init(__n, __c); 21574684ddb6SLionel Sambuc#if _LIBCPP_DEBUG_LEVEL >= 2 21584684ddb6SLionel Sambuc __get_db()->__insert_c(this); 21594684ddb6SLionel Sambuc#endif 21604684ddb6SLionel Sambuc} 21614684ddb6SLionel Sambuc 21624684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 21634684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str, size_type __pos, size_type __n, 21644684ddb6SLionel Sambuc const allocator_type& __a) 21654684ddb6SLionel Sambuc : __r_(__a) 21664684ddb6SLionel Sambuc{ 21674684ddb6SLionel Sambuc size_type __str_sz = __str.size(); 21684684ddb6SLionel Sambuc if (__pos > __str_sz) 21694684ddb6SLionel Sambuc this->__throw_out_of_range(); 21704684ddb6SLionel Sambuc __init(__str.data() + __pos, _VSTD::min(__n, __str_sz - __pos)); 21714684ddb6SLionel Sambuc#if _LIBCPP_DEBUG_LEVEL >= 2 21724684ddb6SLionel Sambuc __get_db()->__insert_c(this); 21734684ddb6SLionel Sambuc#endif 21744684ddb6SLionel Sambuc} 21754684ddb6SLionel Sambuc 21764684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 21774684ddb6SLionel Sambuctemplate <class _InputIterator> 21784684ddb6SLionel Sambuctypename enable_if 21794684ddb6SLionel Sambuc< 21804684ddb6SLionel Sambuc __is_input_iterator <_InputIterator>::value && 21814684ddb6SLionel Sambuc !__is_forward_iterator<_InputIterator>::value, 21824684ddb6SLionel Sambuc void 21834684ddb6SLionel Sambuc>::type 21844684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::__init(_InputIterator __first, _InputIterator __last) 21854684ddb6SLionel Sambuc{ 21864684ddb6SLionel Sambuc __zero(); 21874684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 21884684ddb6SLionel Sambuc try 21894684ddb6SLionel Sambuc { 21904684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 21914684ddb6SLionel Sambuc for (; __first != __last; ++__first) 21924684ddb6SLionel Sambuc push_back(*__first); 21934684ddb6SLionel Sambuc#ifndef _LIBCPP_NO_EXCEPTIONS 21944684ddb6SLionel Sambuc } 21954684ddb6SLionel Sambuc catch (...) 21964684ddb6SLionel Sambuc { 21974684ddb6SLionel Sambuc if (__is_long()) 21984684ddb6SLionel Sambuc __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap()); 21994684ddb6SLionel Sambuc throw; 22004684ddb6SLionel Sambuc } 22014684ddb6SLionel Sambuc#endif // _LIBCPP_NO_EXCEPTIONS 22024684ddb6SLionel Sambuc} 22034684ddb6SLionel Sambuc 22044684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 22054684ddb6SLionel Sambuctemplate <class _ForwardIterator> 22064684ddb6SLionel Sambuctypename enable_if 22074684ddb6SLionel Sambuc< 22084684ddb6SLionel Sambuc __is_forward_iterator<_ForwardIterator>::value, 22094684ddb6SLionel Sambuc void 22104684ddb6SLionel Sambuc>::type 22114684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _ForwardIterator __last) 22124684ddb6SLionel Sambuc{ 22134684ddb6SLionel Sambuc size_type __sz = static_cast<size_type>(_VSTD::distance(__first, __last)); 22144684ddb6SLionel Sambuc if (__sz > max_size()) 22154684ddb6SLionel Sambuc this->__throw_length_error(); 22164684ddb6SLionel Sambuc pointer __p; 22174684ddb6SLionel Sambuc if (__sz < __min_cap) 22184684ddb6SLionel Sambuc { 22194684ddb6SLionel Sambuc __set_short_size(__sz); 22204684ddb6SLionel Sambuc __p = __get_short_pointer(); 22214684ddb6SLionel Sambuc } 22224684ddb6SLionel Sambuc else 22234684ddb6SLionel Sambuc { 22244684ddb6SLionel Sambuc size_type __cap = __recommend(__sz); 22254684ddb6SLionel Sambuc __p = __alloc_traits::allocate(__alloc(), __cap+1); 22264684ddb6SLionel Sambuc __set_long_pointer(__p); 22274684ddb6SLionel Sambuc __set_long_cap(__cap+1); 22284684ddb6SLionel Sambuc __set_long_size(__sz); 22294684ddb6SLionel Sambuc } 2230*0a6a1f1dSLionel Sambuc for (; __first != __last; ++__first, (void) ++__p) 22314684ddb6SLionel Sambuc traits_type::assign(*__p, *__first); 22324684ddb6SLionel Sambuc traits_type::assign(*__p, value_type()); 22334684ddb6SLionel Sambuc} 22344684ddb6SLionel Sambuc 22354684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 22364684ddb6SLionel Sambuctemplate<class _InputIterator> 22374684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 22384684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last) 22394684ddb6SLionel Sambuc{ 22404684ddb6SLionel Sambuc __init(__first, __last); 22414684ddb6SLionel Sambuc#if _LIBCPP_DEBUG_LEVEL >= 2 22424684ddb6SLionel Sambuc __get_db()->__insert_c(this); 22434684ddb6SLionel Sambuc#endif 22444684ddb6SLionel Sambuc} 22454684ddb6SLionel Sambuc 22464684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 22474684ddb6SLionel Sambuctemplate<class _InputIterator> 22484684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 22494684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last, 22504684ddb6SLionel Sambuc const allocator_type& __a) 22514684ddb6SLionel Sambuc : __r_(__a) 22524684ddb6SLionel Sambuc{ 22534684ddb6SLionel Sambuc __init(__first, __last); 22544684ddb6SLionel Sambuc#if _LIBCPP_DEBUG_LEVEL >= 2 22554684ddb6SLionel Sambuc __get_db()->__insert_c(this); 22564684ddb6SLionel Sambuc#endif 22574684ddb6SLionel Sambuc} 22584684ddb6SLionel Sambuc 22594684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 22604684ddb6SLionel Sambuc 22614684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 22624684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 22634684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::basic_string(initializer_list<value_type> __il) 22644684ddb6SLionel Sambuc{ 22654684ddb6SLionel Sambuc __init(__il.begin(), __il.end()); 22664684ddb6SLionel Sambuc#if _LIBCPP_DEBUG_LEVEL >= 2 22674684ddb6SLionel Sambuc __get_db()->__insert_c(this); 22684684ddb6SLionel Sambuc#endif 22694684ddb6SLionel Sambuc} 22704684ddb6SLionel Sambuc 22714684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 22724684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 22734684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::basic_string(initializer_list<value_type> __il, const allocator_type& __a) 22744684ddb6SLionel Sambuc : __r_(__a) 22754684ddb6SLionel Sambuc{ 22764684ddb6SLionel Sambuc __init(__il.begin(), __il.end()); 22774684ddb6SLionel Sambuc#if _LIBCPP_DEBUG_LEVEL >= 2 22784684ddb6SLionel Sambuc __get_db()->__insert_c(this); 22794684ddb6SLionel Sambuc#endif 22804684ddb6SLionel Sambuc} 22814684ddb6SLionel Sambuc 22824684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 22834684ddb6SLionel Sambuc 22844684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 22854684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::~basic_string() 22864684ddb6SLionel Sambuc{ 22874684ddb6SLionel Sambuc#if _LIBCPP_DEBUG_LEVEL >= 2 22884684ddb6SLionel Sambuc __get_db()->__erase_c(this); 22894684ddb6SLionel Sambuc#endif 22904684ddb6SLionel Sambuc if (__is_long()) 22914684ddb6SLionel Sambuc __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap()); 22924684ddb6SLionel Sambuc} 22934684ddb6SLionel Sambuc 22944684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 22954684ddb6SLionel Sambucvoid 22964684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::__grow_by_and_replace 22974684ddb6SLionel Sambuc (size_type __old_cap, size_type __delta_cap, size_type __old_sz, 22984684ddb6SLionel Sambuc size_type __n_copy, size_type __n_del, size_type __n_add, const value_type* __p_new_stuff) 22994684ddb6SLionel Sambuc{ 23004684ddb6SLionel Sambuc size_type __ms = max_size(); 23014684ddb6SLionel Sambuc if (__delta_cap > __ms - __old_cap - 1) 23024684ddb6SLionel Sambuc this->__throw_length_error(); 23034684ddb6SLionel Sambuc pointer __old_p = __get_pointer(); 23044684ddb6SLionel Sambuc size_type __cap = __old_cap < __ms / 2 - __alignment ? 23054684ddb6SLionel Sambuc __recommend(_VSTD::max(__old_cap + __delta_cap, 2 * __old_cap)) : 23064684ddb6SLionel Sambuc __ms - 1; 23074684ddb6SLionel Sambuc pointer __p = __alloc_traits::allocate(__alloc(), __cap+1); 23084684ddb6SLionel Sambuc __invalidate_all_iterators(); 23094684ddb6SLionel Sambuc if (__n_copy != 0) 23104684ddb6SLionel Sambuc traits_type::copy(_VSTD::__to_raw_pointer(__p), 23114684ddb6SLionel Sambuc _VSTD::__to_raw_pointer(__old_p), __n_copy); 23124684ddb6SLionel Sambuc if (__n_add != 0) 23134684ddb6SLionel Sambuc traits_type::copy(_VSTD::__to_raw_pointer(__p) + __n_copy, __p_new_stuff, __n_add); 23144684ddb6SLionel Sambuc size_type __sec_cp_sz = __old_sz - __n_del - __n_copy; 23154684ddb6SLionel Sambuc if (__sec_cp_sz != 0) 23164684ddb6SLionel Sambuc traits_type::copy(_VSTD::__to_raw_pointer(__p) + __n_copy + __n_add, 23174684ddb6SLionel Sambuc _VSTD::__to_raw_pointer(__old_p) + __n_copy + __n_del, __sec_cp_sz); 23184684ddb6SLionel Sambuc if (__old_cap+1 != __min_cap) 23194684ddb6SLionel Sambuc __alloc_traits::deallocate(__alloc(), __old_p, __old_cap+1); 23204684ddb6SLionel Sambuc __set_long_pointer(__p); 23214684ddb6SLionel Sambuc __set_long_cap(__cap+1); 23224684ddb6SLionel Sambuc __old_sz = __n_copy + __n_add + __sec_cp_sz; 23234684ddb6SLionel Sambuc __set_long_size(__old_sz); 23244684ddb6SLionel Sambuc traits_type::assign(__p[__old_sz], value_type()); 23254684ddb6SLionel Sambuc} 23264684ddb6SLionel Sambuc 23274684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 23284684ddb6SLionel Sambucvoid 23294684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::__grow_by(size_type __old_cap, size_type __delta_cap, size_type __old_sz, 23304684ddb6SLionel Sambuc size_type __n_copy, size_type __n_del, size_type __n_add) 23314684ddb6SLionel Sambuc{ 23324684ddb6SLionel Sambuc size_type __ms = max_size(); 23334684ddb6SLionel Sambuc if (__delta_cap > __ms - __old_cap) 23344684ddb6SLionel Sambuc this->__throw_length_error(); 23354684ddb6SLionel Sambuc pointer __old_p = __get_pointer(); 23364684ddb6SLionel Sambuc size_type __cap = __old_cap < __ms / 2 - __alignment ? 23374684ddb6SLionel Sambuc __recommend(_VSTD::max(__old_cap + __delta_cap, 2 * __old_cap)) : 23384684ddb6SLionel Sambuc __ms - 1; 23394684ddb6SLionel Sambuc pointer __p = __alloc_traits::allocate(__alloc(), __cap+1); 23404684ddb6SLionel Sambuc __invalidate_all_iterators(); 23414684ddb6SLionel Sambuc if (__n_copy != 0) 23424684ddb6SLionel Sambuc traits_type::copy(_VSTD::__to_raw_pointer(__p), 23434684ddb6SLionel Sambuc _VSTD::__to_raw_pointer(__old_p), __n_copy); 23444684ddb6SLionel Sambuc size_type __sec_cp_sz = __old_sz - __n_del - __n_copy; 23454684ddb6SLionel Sambuc if (__sec_cp_sz != 0) 23464684ddb6SLionel Sambuc traits_type::copy(_VSTD::__to_raw_pointer(__p) + __n_copy + __n_add, 23474684ddb6SLionel Sambuc _VSTD::__to_raw_pointer(__old_p) + __n_copy + __n_del, 23484684ddb6SLionel Sambuc __sec_cp_sz); 23494684ddb6SLionel Sambuc if (__old_cap+1 != __min_cap) 23504684ddb6SLionel Sambuc __alloc_traits::deallocate(__alloc(), __old_p, __old_cap+1); 23514684ddb6SLionel Sambuc __set_long_pointer(__p); 23524684ddb6SLionel Sambuc __set_long_cap(__cap+1); 23534684ddb6SLionel Sambuc} 23544684ddb6SLionel Sambuc 23554684ddb6SLionel Sambuc// assign 23564684ddb6SLionel Sambuc 23574684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 23584684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>& 23594684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_type __n) 23604684ddb6SLionel Sambuc{ 2361*0a6a1f1dSLionel Sambuc _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::assign received nullptr"); 23624684ddb6SLionel Sambuc size_type __cap = capacity(); 23634684ddb6SLionel Sambuc if (__cap >= __n) 23644684ddb6SLionel Sambuc { 23654684ddb6SLionel Sambuc value_type* __p = _VSTD::__to_raw_pointer(__get_pointer()); 23664684ddb6SLionel Sambuc traits_type::move(__p, __s, __n); 23674684ddb6SLionel Sambuc traits_type::assign(__p[__n], value_type()); 23684684ddb6SLionel Sambuc __set_size(__n); 23694684ddb6SLionel Sambuc __invalidate_iterators_past(__n); 23704684ddb6SLionel Sambuc } 23714684ddb6SLionel Sambuc else 23724684ddb6SLionel Sambuc { 23734684ddb6SLionel Sambuc size_type __sz = size(); 23744684ddb6SLionel Sambuc __grow_by_and_replace(__cap, __n - __cap, __sz, 0, __sz, __n, __s); 23754684ddb6SLionel Sambuc } 23764684ddb6SLionel Sambuc return *this; 23774684ddb6SLionel Sambuc} 23784684ddb6SLionel Sambuc 23794684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 23804684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>& 23814684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c) 23824684ddb6SLionel Sambuc{ 23834684ddb6SLionel Sambuc size_type __cap = capacity(); 23844684ddb6SLionel Sambuc if (__cap < __n) 23854684ddb6SLionel Sambuc { 23864684ddb6SLionel Sambuc size_type __sz = size(); 23874684ddb6SLionel Sambuc __grow_by(__cap, __n - __cap, __sz, 0, __sz); 23884684ddb6SLionel Sambuc } 23894684ddb6SLionel Sambuc else 23904684ddb6SLionel Sambuc __invalidate_iterators_past(__n); 23914684ddb6SLionel Sambuc value_type* __p = _VSTD::__to_raw_pointer(__get_pointer()); 23924684ddb6SLionel Sambuc traits_type::assign(__p, __n, __c); 23934684ddb6SLionel Sambuc traits_type::assign(__p[__n], value_type()); 23944684ddb6SLionel Sambuc __set_size(__n); 23954684ddb6SLionel Sambuc return *this; 23964684ddb6SLionel Sambuc} 23974684ddb6SLionel Sambuc 23984684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 23994684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>& 24004684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::operator=(value_type __c) 24014684ddb6SLionel Sambuc{ 24024684ddb6SLionel Sambuc pointer __p; 24034684ddb6SLionel Sambuc if (__is_long()) 24044684ddb6SLionel Sambuc { 24054684ddb6SLionel Sambuc __p = __get_long_pointer(); 24064684ddb6SLionel Sambuc __set_long_size(1); 24074684ddb6SLionel Sambuc } 24084684ddb6SLionel Sambuc else 24094684ddb6SLionel Sambuc { 24104684ddb6SLionel Sambuc __p = __get_short_pointer(); 24114684ddb6SLionel Sambuc __set_short_size(1); 24124684ddb6SLionel Sambuc } 24134684ddb6SLionel Sambuc traits_type::assign(*__p, __c); 24144684ddb6SLionel Sambuc traits_type::assign(*++__p, value_type()); 24154684ddb6SLionel Sambuc __invalidate_iterators_past(1); 24164684ddb6SLionel Sambuc return *this; 24174684ddb6SLionel Sambuc} 24184684ddb6SLionel Sambuc 24194684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 24204684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>& 24214684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str) 24224684ddb6SLionel Sambuc{ 24234684ddb6SLionel Sambuc if (this != &__str) 24244684ddb6SLionel Sambuc { 24254684ddb6SLionel Sambuc __copy_assign_alloc(__str); 24264684ddb6SLionel Sambuc assign(__str); 24274684ddb6SLionel Sambuc } 24284684ddb6SLionel Sambuc return *this; 24294684ddb6SLionel Sambuc} 24304684ddb6SLionel Sambuc 24314684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 24324684ddb6SLionel Sambuc 24334684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 24344684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 24354684ddb6SLionel Sambucvoid 24364684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, false_type) 2437*0a6a1f1dSLionel Sambuc _NOEXCEPT_(__alloc_traits::is_always_equal::value) 24384684ddb6SLionel Sambuc{ 24394684ddb6SLionel Sambuc if (__alloc() != __str.__alloc()) 24404684ddb6SLionel Sambuc assign(__str); 24414684ddb6SLionel Sambuc else 24424684ddb6SLionel Sambuc __move_assign(__str, true_type()); 24434684ddb6SLionel Sambuc} 24444684ddb6SLionel Sambuc 24454684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 24464684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 24474684ddb6SLionel Sambucvoid 24484684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, true_type) 2449*0a6a1f1dSLionel Sambuc#if _LIBCPP_STD_VER > 14 2450*0a6a1f1dSLionel Sambuc _NOEXCEPT 2451*0a6a1f1dSLionel Sambuc#else 24524684ddb6SLionel Sambuc _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) 2453*0a6a1f1dSLionel Sambuc#endif 24544684ddb6SLionel Sambuc{ 24554684ddb6SLionel Sambuc clear(); 24564684ddb6SLionel Sambuc shrink_to_fit(); 24574684ddb6SLionel Sambuc __r_.first() = __str.__r_.first(); 24584684ddb6SLionel Sambuc __move_assign_alloc(__str); 24594684ddb6SLionel Sambuc __str.__zero(); 24604684ddb6SLionel Sambuc} 24614684ddb6SLionel Sambuc 24624684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 24634684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 24644684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>& 24654684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::operator=(basic_string&& __str) 2466*0a6a1f1dSLionel Sambuc _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) 24674684ddb6SLionel Sambuc{ 24684684ddb6SLionel Sambuc __move_assign(__str, integral_constant<bool, 24694684ddb6SLionel Sambuc __alloc_traits::propagate_on_container_move_assignment::value>()); 24704684ddb6SLionel Sambuc return *this; 24714684ddb6SLionel Sambuc} 24724684ddb6SLionel Sambuc 24734684ddb6SLionel Sambuc#endif 24744684ddb6SLionel Sambuc 24754684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 24764684ddb6SLionel Sambuctemplate<class _InputIterator> 24774684ddb6SLionel Sambuctypename enable_if 24784684ddb6SLionel Sambuc< 24794684ddb6SLionel Sambuc __is_input_iterator <_InputIterator>::value && 24804684ddb6SLionel Sambuc !__is_forward_iterator<_InputIterator>::value, 24814684ddb6SLionel Sambuc basic_string<_CharT, _Traits, _Allocator>& 24824684ddb6SLionel Sambuc>::type 24834684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::assign(_InputIterator __first, _InputIterator __last) 24844684ddb6SLionel Sambuc{ 24854684ddb6SLionel Sambuc clear(); 24864684ddb6SLionel Sambuc for (; __first != __last; ++__first) 24874684ddb6SLionel Sambuc push_back(*__first); 24884684ddb6SLionel Sambuc return *this; 24894684ddb6SLionel Sambuc} 24904684ddb6SLionel Sambuc 24914684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 24924684ddb6SLionel Sambuctemplate<class _ForwardIterator> 24934684ddb6SLionel Sambuctypename enable_if 24944684ddb6SLionel Sambuc< 24954684ddb6SLionel Sambuc __is_forward_iterator<_ForwardIterator>::value, 24964684ddb6SLionel Sambuc basic_string<_CharT, _Traits, _Allocator>& 24974684ddb6SLionel Sambuc>::type 24984684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last) 24994684ddb6SLionel Sambuc{ 25004684ddb6SLionel Sambuc size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last)); 25014684ddb6SLionel Sambuc size_type __cap = capacity(); 25024684ddb6SLionel Sambuc if (__cap < __n) 25034684ddb6SLionel Sambuc { 25044684ddb6SLionel Sambuc size_type __sz = size(); 25054684ddb6SLionel Sambuc __grow_by(__cap, __n - __cap, __sz, 0, __sz); 25064684ddb6SLionel Sambuc } 25074684ddb6SLionel Sambuc else 25084684ddb6SLionel Sambuc __invalidate_iterators_past(__n); 25094684ddb6SLionel Sambuc pointer __p = __get_pointer(); 25104684ddb6SLionel Sambuc for (; __first != __last; ++__first, ++__p) 25114684ddb6SLionel Sambuc traits_type::assign(*__p, *__first); 25124684ddb6SLionel Sambuc traits_type::assign(*__p, value_type()); 25134684ddb6SLionel Sambuc __set_size(__n); 25144684ddb6SLionel Sambuc return *this; 25154684ddb6SLionel Sambuc} 25164684ddb6SLionel Sambuc 25174684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 25184684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 25194684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>& 25204684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::assign(const basic_string& __str) 25214684ddb6SLionel Sambuc{ 25224684ddb6SLionel Sambuc return assign(__str.data(), __str.size()); 25234684ddb6SLionel Sambuc} 25244684ddb6SLionel Sambuc 25254684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 25264684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>& 25274684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::assign(const basic_string& __str, size_type __pos, size_type __n) 25284684ddb6SLionel Sambuc{ 25294684ddb6SLionel Sambuc size_type __sz = __str.size(); 25304684ddb6SLionel Sambuc if (__pos > __sz) 25314684ddb6SLionel Sambuc this->__throw_out_of_range(); 25324684ddb6SLionel Sambuc return assign(__str.data() + __pos, _VSTD::min(__n, __sz - __pos)); 25334684ddb6SLionel Sambuc} 25344684ddb6SLionel Sambuc 25354684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 25364684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>& 25374684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s) 25384684ddb6SLionel Sambuc{ 2539*0a6a1f1dSLionel Sambuc _LIBCPP_ASSERT(__s != nullptr, "string::assign received nullptr"); 25404684ddb6SLionel Sambuc return assign(__s, traits_type::length(__s)); 25414684ddb6SLionel Sambuc} 25424684ddb6SLionel Sambuc 25434684ddb6SLionel Sambuc// append 25444684ddb6SLionel Sambuc 25454684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 25464684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>& 25474684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_type __n) 25484684ddb6SLionel Sambuc{ 2549*0a6a1f1dSLionel Sambuc _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::append received nullptr"); 25504684ddb6SLionel Sambuc size_type __cap = capacity(); 25514684ddb6SLionel Sambuc size_type __sz = size(); 25524684ddb6SLionel Sambuc if (__cap - __sz >= __n) 25534684ddb6SLionel Sambuc { 25544684ddb6SLionel Sambuc if (__n) 25554684ddb6SLionel Sambuc { 25564684ddb6SLionel Sambuc value_type* __p = _VSTD::__to_raw_pointer(__get_pointer()); 25574684ddb6SLionel Sambuc traits_type::copy(__p + __sz, __s, __n); 25584684ddb6SLionel Sambuc __sz += __n; 25594684ddb6SLionel Sambuc __set_size(__sz); 25604684ddb6SLionel Sambuc traits_type::assign(__p[__sz], value_type()); 25614684ddb6SLionel Sambuc } 25624684ddb6SLionel Sambuc } 25634684ddb6SLionel Sambuc else 25644684ddb6SLionel Sambuc __grow_by_and_replace(__cap, __sz + __n - __cap, __sz, __sz, 0, __n, __s); 25654684ddb6SLionel Sambuc return *this; 25664684ddb6SLionel Sambuc} 25674684ddb6SLionel Sambuc 25684684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 25694684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>& 25704684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::append(size_type __n, value_type __c) 25714684ddb6SLionel Sambuc{ 25724684ddb6SLionel Sambuc if (__n) 25734684ddb6SLionel Sambuc { 25744684ddb6SLionel Sambuc size_type __cap = capacity(); 25754684ddb6SLionel Sambuc size_type __sz = size(); 25764684ddb6SLionel Sambuc if (__cap - __sz < __n) 25774684ddb6SLionel Sambuc __grow_by(__cap, __sz + __n - __cap, __sz, __sz, 0); 25784684ddb6SLionel Sambuc pointer __p = __get_pointer(); 25794684ddb6SLionel Sambuc traits_type::assign(_VSTD::__to_raw_pointer(__p) + __sz, __n, __c); 25804684ddb6SLionel Sambuc __sz += __n; 25814684ddb6SLionel Sambuc __set_size(__sz); 25824684ddb6SLionel Sambuc traits_type::assign(__p[__sz], value_type()); 25834684ddb6SLionel Sambuc } 25844684ddb6SLionel Sambuc return *this; 25854684ddb6SLionel Sambuc} 25864684ddb6SLionel Sambuc 25874684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 25884684ddb6SLionel Sambucvoid 25894684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::push_back(value_type __c) 25904684ddb6SLionel Sambuc{ 25914684ddb6SLionel Sambuc bool __is_short = !__is_long(); 25924684ddb6SLionel Sambuc size_type __cap; 25934684ddb6SLionel Sambuc size_type __sz; 25944684ddb6SLionel Sambuc if (__is_short) 25954684ddb6SLionel Sambuc { 25964684ddb6SLionel Sambuc __cap = __min_cap - 1; 25974684ddb6SLionel Sambuc __sz = __get_short_size(); 25984684ddb6SLionel Sambuc } 25994684ddb6SLionel Sambuc else 26004684ddb6SLionel Sambuc { 26014684ddb6SLionel Sambuc __cap = __get_long_cap() - 1; 26024684ddb6SLionel Sambuc __sz = __get_long_size(); 26034684ddb6SLionel Sambuc } 26044684ddb6SLionel Sambuc if (__sz == __cap) 26054684ddb6SLionel Sambuc { 26064684ddb6SLionel Sambuc __grow_by(__cap, 1, __sz, __sz, 0); 26074684ddb6SLionel Sambuc __is_short = !__is_long(); 26084684ddb6SLionel Sambuc } 26094684ddb6SLionel Sambuc pointer __p; 26104684ddb6SLionel Sambuc if (__is_short) 26114684ddb6SLionel Sambuc { 26124684ddb6SLionel Sambuc __p = __get_short_pointer() + __sz; 26134684ddb6SLionel Sambuc __set_short_size(__sz+1); 26144684ddb6SLionel Sambuc } 26154684ddb6SLionel Sambuc else 26164684ddb6SLionel Sambuc { 26174684ddb6SLionel Sambuc __p = __get_long_pointer() + __sz; 26184684ddb6SLionel Sambuc __set_long_size(__sz+1); 26194684ddb6SLionel Sambuc } 26204684ddb6SLionel Sambuc traits_type::assign(*__p, __c); 26214684ddb6SLionel Sambuc traits_type::assign(*++__p, value_type()); 26224684ddb6SLionel Sambuc} 26234684ddb6SLionel Sambuc 26244684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 26254684ddb6SLionel Sambuctemplate<class _InputIterator> 26264684ddb6SLionel Sambuctypename enable_if 26274684ddb6SLionel Sambuc< 26284684ddb6SLionel Sambuc __is_input_iterator <_InputIterator>::value && 26294684ddb6SLionel Sambuc !__is_forward_iterator<_InputIterator>::value, 26304684ddb6SLionel Sambuc basic_string<_CharT, _Traits, _Allocator>& 26314684ddb6SLionel Sambuc>::type 26324684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::append(_InputIterator __first, _InputIterator __last) 26334684ddb6SLionel Sambuc{ 26344684ddb6SLionel Sambuc for (; __first != __last; ++__first) 26354684ddb6SLionel Sambuc push_back(*__first); 26364684ddb6SLionel Sambuc return *this; 26374684ddb6SLionel Sambuc} 26384684ddb6SLionel Sambuc 26394684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 26404684ddb6SLionel Sambuctemplate<class _ForwardIterator> 26414684ddb6SLionel Sambuctypename enable_if 26424684ddb6SLionel Sambuc< 26434684ddb6SLionel Sambuc __is_forward_iterator<_ForwardIterator>::value, 26444684ddb6SLionel Sambuc basic_string<_CharT, _Traits, _Allocator>& 26454684ddb6SLionel Sambuc>::type 26464684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::append(_ForwardIterator __first, _ForwardIterator __last) 26474684ddb6SLionel Sambuc{ 26484684ddb6SLionel Sambuc size_type __sz = size(); 26494684ddb6SLionel Sambuc size_type __cap = capacity(); 26504684ddb6SLionel Sambuc size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last)); 26514684ddb6SLionel Sambuc if (__n) 26524684ddb6SLionel Sambuc { 26534684ddb6SLionel Sambuc if (__cap - __sz < __n) 26544684ddb6SLionel Sambuc __grow_by(__cap, __sz + __n - __cap, __sz, __sz, 0); 26554684ddb6SLionel Sambuc pointer __p = __get_pointer() + __sz; 26564684ddb6SLionel Sambuc for (; __first != __last; ++__p, ++__first) 26574684ddb6SLionel Sambuc traits_type::assign(*__p, *__first); 26584684ddb6SLionel Sambuc traits_type::assign(*__p, value_type()); 26594684ddb6SLionel Sambuc __set_size(__sz + __n); 26604684ddb6SLionel Sambuc } 26614684ddb6SLionel Sambuc return *this; 26624684ddb6SLionel Sambuc} 26634684ddb6SLionel Sambuc 26644684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 26654684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 26664684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>& 26674684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str) 26684684ddb6SLionel Sambuc{ 26694684ddb6SLionel Sambuc return append(__str.data(), __str.size()); 26704684ddb6SLionel Sambuc} 26714684ddb6SLionel Sambuc 26724684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 26734684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>& 26744684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str, size_type __pos, size_type __n) 26754684ddb6SLionel Sambuc{ 26764684ddb6SLionel Sambuc size_type __sz = __str.size(); 26774684ddb6SLionel Sambuc if (__pos > __sz) 26784684ddb6SLionel Sambuc this->__throw_out_of_range(); 26794684ddb6SLionel Sambuc return append(__str.data() + __pos, _VSTD::min(__n, __sz - __pos)); 26804684ddb6SLionel Sambuc} 26814684ddb6SLionel Sambuc 26824684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 26834684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>& 26844684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s) 26854684ddb6SLionel Sambuc{ 2686*0a6a1f1dSLionel Sambuc _LIBCPP_ASSERT(__s != nullptr, "string::append received nullptr"); 26874684ddb6SLionel Sambuc return append(__s, traits_type::length(__s)); 26884684ddb6SLionel Sambuc} 26894684ddb6SLionel Sambuc 26904684ddb6SLionel Sambuc// insert 26914684ddb6SLionel Sambuc 26924684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 26934684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>& 26944684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s, size_type __n) 26954684ddb6SLionel Sambuc{ 2696*0a6a1f1dSLionel Sambuc _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::insert received nullptr"); 26974684ddb6SLionel Sambuc size_type __sz = size(); 26984684ddb6SLionel Sambuc if (__pos > __sz) 26994684ddb6SLionel Sambuc this->__throw_out_of_range(); 27004684ddb6SLionel Sambuc size_type __cap = capacity(); 27014684ddb6SLionel Sambuc if (__cap - __sz >= __n) 27024684ddb6SLionel Sambuc { 27034684ddb6SLionel Sambuc if (__n) 27044684ddb6SLionel Sambuc { 27054684ddb6SLionel Sambuc value_type* __p = _VSTD::__to_raw_pointer(__get_pointer()); 27064684ddb6SLionel Sambuc size_type __n_move = __sz - __pos; 27074684ddb6SLionel Sambuc if (__n_move != 0) 27084684ddb6SLionel Sambuc { 27094684ddb6SLionel Sambuc if (__p + __pos <= __s && __s < __p + __sz) 27104684ddb6SLionel Sambuc __s += __n; 27114684ddb6SLionel Sambuc traits_type::move(__p + __pos + __n, __p + __pos, __n_move); 27124684ddb6SLionel Sambuc } 27134684ddb6SLionel Sambuc traits_type::move(__p + __pos, __s, __n); 27144684ddb6SLionel Sambuc __sz += __n; 27154684ddb6SLionel Sambuc __set_size(__sz); 27164684ddb6SLionel Sambuc traits_type::assign(__p[__sz], value_type()); 27174684ddb6SLionel Sambuc } 27184684ddb6SLionel Sambuc } 27194684ddb6SLionel Sambuc else 27204684ddb6SLionel Sambuc __grow_by_and_replace(__cap, __sz + __n - __cap, __sz, __pos, 0, __n, __s); 27214684ddb6SLionel Sambuc return *this; 27224684ddb6SLionel Sambuc} 27234684ddb6SLionel Sambuc 27244684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 27254684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>& 27264684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n, value_type __c) 27274684ddb6SLionel Sambuc{ 27284684ddb6SLionel Sambuc size_type __sz = size(); 27294684ddb6SLionel Sambuc if (__pos > __sz) 27304684ddb6SLionel Sambuc this->__throw_out_of_range(); 27314684ddb6SLionel Sambuc if (__n) 27324684ddb6SLionel Sambuc { 27334684ddb6SLionel Sambuc size_type __cap = capacity(); 27344684ddb6SLionel Sambuc value_type* __p; 27354684ddb6SLionel Sambuc if (__cap - __sz >= __n) 27364684ddb6SLionel Sambuc { 27374684ddb6SLionel Sambuc __p = _VSTD::__to_raw_pointer(__get_pointer()); 27384684ddb6SLionel Sambuc size_type __n_move = __sz - __pos; 27394684ddb6SLionel Sambuc if (__n_move != 0) 27404684ddb6SLionel Sambuc traits_type::move(__p + __pos + __n, __p + __pos, __n_move); 27414684ddb6SLionel Sambuc } 27424684ddb6SLionel Sambuc else 27434684ddb6SLionel Sambuc { 27444684ddb6SLionel Sambuc __grow_by(__cap, __sz + __n - __cap, __sz, __pos, 0, __n); 27454684ddb6SLionel Sambuc __p = _VSTD::__to_raw_pointer(__get_long_pointer()); 27464684ddb6SLionel Sambuc } 27474684ddb6SLionel Sambuc traits_type::assign(__p + __pos, __n, __c); 27484684ddb6SLionel Sambuc __sz += __n; 27494684ddb6SLionel Sambuc __set_size(__sz); 27504684ddb6SLionel Sambuc traits_type::assign(__p[__sz], value_type()); 27514684ddb6SLionel Sambuc } 27524684ddb6SLionel Sambuc return *this; 27534684ddb6SLionel Sambuc} 27544684ddb6SLionel Sambuc 27554684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 27564684ddb6SLionel Sambuctemplate<class _InputIterator> 27574684ddb6SLionel Sambuctypename enable_if 27584684ddb6SLionel Sambuc< 27594684ddb6SLionel Sambuc __is_input_iterator <_InputIterator>::value && 27604684ddb6SLionel Sambuc !__is_forward_iterator<_InputIterator>::value, 27614684ddb6SLionel Sambuc typename basic_string<_CharT, _Traits, _Allocator>::iterator 27624684ddb6SLionel Sambuc>::type 27634684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIterator __first, _InputIterator __last) 27644684ddb6SLionel Sambuc{ 27654684ddb6SLionel Sambuc#if _LIBCPP_DEBUG_LEVEL >= 2 27664684ddb6SLionel Sambuc _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, 27674684ddb6SLionel Sambuc "string::insert(iterator, range) called with an iterator not" 27684684ddb6SLionel Sambuc " referring to this string"); 27694684ddb6SLionel Sambuc#endif 27704684ddb6SLionel Sambuc size_type __old_sz = size(); 27714684ddb6SLionel Sambuc difference_type __ip = __pos - begin(); 27724684ddb6SLionel Sambuc for (; __first != __last; ++__first) 27734684ddb6SLionel Sambuc push_back(*__first); 27744684ddb6SLionel Sambuc pointer __p = __get_pointer(); 27754684ddb6SLionel Sambuc _VSTD::rotate(__p + __ip, __p + __old_sz, __p + size()); 27764684ddb6SLionel Sambuc#if _LIBCPP_DEBUG_LEVEL >= 2 27774684ddb6SLionel Sambuc return iterator(this, __p + __ip); 27784684ddb6SLionel Sambuc#else 27794684ddb6SLionel Sambuc return iterator(__p + __ip); 27804684ddb6SLionel Sambuc#endif 27814684ddb6SLionel Sambuc} 27824684ddb6SLionel Sambuc 27834684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 27844684ddb6SLionel Sambuctemplate<class _ForwardIterator> 27854684ddb6SLionel Sambuctypename enable_if 27864684ddb6SLionel Sambuc< 27874684ddb6SLionel Sambuc __is_forward_iterator<_ForwardIterator>::value, 27884684ddb6SLionel Sambuc typename basic_string<_CharT, _Traits, _Allocator>::iterator 27894684ddb6SLionel Sambuc>::type 27904684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last) 27914684ddb6SLionel Sambuc{ 27924684ddb6SLionel Sambuc#if _LIBCPP_DEBUG_LEVEL >= 2 27934684ddb6SLionel Sambuc _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, 27944684ddb6SLionel Sambuc "string::insert(iterator, range) called with an iterator not" 27954684ddb6SLionel Sambuc " referring to this string"); 27964684ddb6SLionel Sambuc#endif 27974684ddb6SLionel Sambuc size_type __ip = static_cast<size_type>(__pos - begin()); 27984684ddb6SLionel Sambuc size_type __sz = size(); 27994684ddb6SLionel Sambuc size_type __cap = capacity(); 28004684ddb6SLionel Sambuc size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last)); 28014684ddb6SLionel Sambuc if (__n) 28024684ddb6SLionel Sambuc { 28034684ddb6SLionel Sambuc value_type* __p; 28044684ddb6SLionel Sambuc if (__cap - __sz >= __n) 28054684ddb6SLionel Sambuc { 28064684ddb6SLionel Sambuc __p = _VSTD::__to_raw_pointer(__get_pointer()); 28074684ddb6SLionel Sambuc size_type __n_move = __sz - __ip; 28084684ddb6SLionel Sambuc if (__n_move != 0) 28094684ddb6SLionel Sambuc traits_type::move(__p + __ip + __n, __p + __ip, __n_move); 28104684ddb6SLionel Sambuc } 28114684ddb6SLionel Sambuc else 28124684ddb6SLionel Sambuc { 28134684ddb6SLionel Sambuc __grow_by(__cap, __sz + __n - __cap, __sz, __ip, 0, __n); 28144684ddb6SLionel Sambuc __p = _VSTD::__to_raw_pointer(__get_long_pointer()); 28154684ddb6SLionel Sambuc } 28164684ddb6SLionel Sambuc __sz += __n; 28174684ddb6SLionel Sambuc __set_size(__sz); 28184684ddb6SLionel Sambuc traits_type::assign(__p[__sz], value_type()); 28194684ddb6SLionel Sambuc for (__p += __ip; __first != __last; ++__p, ++__first) 28204684ddb6SLionel Sambuc traits_type::assign(*__p, *__first); 28214684ddb6SLionel Sambuc } 28224684ddb6SLionel Sambuc return begin() + __ip; 28234684ddb6SLionel Sambuc} 28244684ddb6SLionel Sambuc 28254684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 28264684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 28274684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>& 28284684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_string& __str) 28294684ddb6SLionel Sambuc{ 28304684ddb6SLionel Sambuc return insert(__pos1, __str.data(), __str.size()); 28314684ddb6SLionel Sambuc} 28324684ddb6SLionel Sambuc 28334684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 28344684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>& 28354684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_string& __str, 28364684ddb6SLionel Sambuc size_type __pos2, size_type __n) 28374684ddb6SLionel Sambuc{ 28384684ddb6SLionel Sambuc size_type __str_sz = __str.size(); 28394684ddb6SLionel Sambuc if (__pos2 > __str_sz) 28404684ddb6SLionel Sambuc this->__throw_out_of_range(); 28414684ddb6SLionel Sambuc return insert(__pos1, __str.data() + __pos2, _VSTD::min(__n, __str_sz - __pos2)); 28424684ddb6SLionel Sambuc} 28434684ddb6SLionel Sambuc 28444684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 28454684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>& 28464684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s) 28474684ddb6SLionel Sambuc{ 2848*0a6a1f1dSLionel Sambuc _LIBCPP_ASSERT(__s != nullptr, "string::insert received nullptr"); 28494684ddb6SLionel Sambuc return insert(__pos, __s, traits_type::length(__s)); 28504684ddb6SLionel Sambuc} 28514684ddb6SLionel Sambuc 28524684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 28534684ddb6SLionel Sambuctypename basic_string<_CharT, _Traits, _Allocator>::iterator 28544684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, value_type __c) 28554684ddb6SLionel Sambuc{ 28564684ddb6SLionel Sambuc size_type __ip = static_cast<size_type>(__pos - begin()); 28574684ddb6SLionel Sambuc size_type __sz = size(); 28584684ddb6SLionel Sambuc size_type __cap = capacity(); 28594684ddb6SLionel Sambuc value_type* __p; 28604684ddb6SLionel Sambuc if (__cap == __sz) 28614684ddb6SLionel Sambuc { 28624684ddb6SLionel Sambuc __grow_by(__cap, 1, __sz, __ip, 0, 1); 28634684ddb6SLionel Sambuc __p = _VSTD::__to_raw_pointer(__get_long_pointer()); 28644684ddb6SLionel Sambuc } 28654684ddb6SLionel Sambuc else 28664684ddb6SLionel Sambuc { 28674684ddb6SLionel Sambuc __p = _VSTD::__to_raw_pointer(__get_pointer()); 28684684ddb6SLionel Sambuc size_type __n_move = __sz - __ip; 28694684ddb6SLionel Sambuc if (__n_move != 0) 28704684ddb6SLionel Sambuc traits_type::move(__p + __ip + 1, __p + __ip, __n_move); 28714684ddb6SLionel Sambuc } 28724684ddb6SLionel Sambuc traits_type::assign(__p[__ip], __c); 28734684ddb6SLionel Sambuc traits_type::assign(__p[++__sz], value_type()); 28744684ddb6SLionel Sambuc __set_size(__sz); 28754684ddb6SLionel Sambuc return begin() + static_cast<difference_type>(__ip); 28764684ddb6SLionel Sambuc} 28774684ddb6SLionel Sambuc 28784684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 28794684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 28804684ddb6SLionel Sambuctypename basic_string<_CharT, _Traits, _Allocator>::iterator 28814684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, size_type __n, value_type __c) 28824684ddb6SLionel Sambuc{ 28834684ddb6SLionel Sambuc#if _LIBCPP_DEBUG_LEVEL >= 2 28844684ddb6SLionel Sambuc _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, 28854684ddb6SLionel Sambuc "string::insert(iterator, n, value) called with an iterator not" 28864684ddb6SLionel Sambuc " referring to this string"); 28874684ddb6SLionel Sambuc#endif 28884684ddb6SLionel Sambuc difference_type __p = __pos - begin(); 28894684ddb6SLionel Sambuc insert(static_cast<size_type>(__p), __n, __c); 28904684ddb6SLionel Sambuc return begin() + __p; 28914684ddb6SLionel Sambuc} 28924684ddb6SLionel Sambuc 28934684ddb6SLionel Sambuc// replace 28944684ddb6SLionel Sambuc 28954684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 28964684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>& 28974684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2) 28984684ddb6SLionel Sambuc{ 2899*0a6a1f1dSLionel Sambuc _LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::replace received nullptr"); 29004684ddb6SLionel Sambuc size_type __sz = size(); 29014684ddb6SLionel Sambuc if (__pos > __sz) 29024684ddb6SLionel Sambuc this->__throw_out_of_range(); 29034684ddb6SLionel Sambuc __n1 = _VSTD::min(__n1, __sz - __pos); 29044684ddb6SLionel Sambuc size_type __cap = capacity(); 29054684ddb6SLionel Sambuc if (__cap - __sz + __n1 >= __n2) 29064684ddb6SLionel Sambuc { 29074684ddb6SLionel Sambuc value_type* __p = _VSTD::__to_raw_pointer(__get_pointer()); 29084684ddb6SLionel Sambuc if (__n1 != __n2) 29094684ddb6SLionel Sambuc { 29104684ddb6SLionel Sambuc size_type __n_move = __sz - __pos - __n1; 29114684ddb6SLionel Sambuc if (__n_move != 0) 29124684ddb6SLionel Sambuc { 29134684ddb6SLionel Sambuc if (__n1 > __n2) 29144684ddb6SLionel Sambuc { 29154684ddb6SLionel Sambuc traits_type::move(__p + __pos, __s, __n2); 29164684ddb6SLionel Sambuc traits_type::move(__p + __pos + __n2, __p + __pos + __n1, __n_move); 29174684ddb6SLionel Sambuc goto __finish; 29184684ddb6SLionel Sambuc } 29194684ddb6SLionel Sambuc if (__p + __pos < __s && __s < __p + __sz) 29204684ddb6SLionel Sambuc { 29214684ddb6SLionel Sambuc if (__p + __pos + __n1 <= __s) 29224684ddb6SLionel Sambuc __s += __n2 - __n1; 29234684ddb6SLionel Sambuc else // __p + __pos < __s < __p + __pos + __n1 29244684ddb6SLionel Sambuc { 29254684ddb6SLionel Sambuc traits_type::move(__p + __pos, __s, __n1); 29264684ddb6SLionel Sambuc __pos += __n1; 29274684ddb6SLionel Sambuc __s += __n2; 29284684ddb6SLionel Sambuc __n2 -= __n1; 29294684ddb6SLionel Sambuc __n1 = 0; 29304684ddb6SLionel Sambuc } 29314684ddb6SLionel Sambuc } 29324684ddb6SLionel Sambuc traits_type::move(__p + __pos + __n2, __p + __pos + __n1, __n_move); 29334684ddb6SLionel Sambuc } 29344684ddb6SLionel Sambuc } 29354684ddb6SLionel Sambuc traits_type::move(__p + __pos, __s, __n2); 29364684ddb6SLionel Sambuc__finish: 29374684ddb6SLionel Sambuc __sz += __n2 - __n1; 29384684ddb6SLionel Sambuc __set_size(__sz); 29394684ddb6SLionel Sambuc __invalidate_iterators_past(__sz); 29404684ddb6SLionel Sambuc traits_type::assign(__p[__sz], value_type()); 29414684ddb6SLionel Sambuc } 29424684ddb6SLionel Sambuc else 29434684ddb6SLionel Sambuc __grow_by_and_replace(__cap, __sz - __n1 + __n2 - __cap, __sz, __pos, __n1, __n2, __s); 29444684ddb6SLionel Sambuc return *this; 29454684ddb6SLionel Sambuc} 29464684ddb6SLionel Sambuc 29474684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 29484684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>& 29494684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, size_type __n2, value_type __c) 29504684ddb6SLionel Sambuc{ 29514684ddb6SLionel Sambuc size_type __sz = size(); 29524684ddb6SLionel Sambuc if (__pos > __sz) 29534684ddb6SLionel Sambuc this->__throw_out_of_range(); 29544684ddb6SLionel Sambuc __n1 = _VSTD::min(__n1, __sz - __pos); 29554684ddb6SLionel Sambuc size_type __cap = capacity(); 29564684ddb6SLionel Sambuc value_type* __p; 29574684ddb6SLionel Sambuc if (__cap - __sz + __n1 >= __n2) 29584684ddb6SLionel Sambuc { 29594684ddb6SLionel Sambuc __p = _VSTD::__to_raw_pointer(__get_pointer()); 29604684ddb6SLionel Sambuc if (__n1 != __n2) 29614684ddb6SLionel Sambuc { 29624684ddb6SLionel Sambuc size_type __n_move = __sz - __pos - __n1; 29634684ddb6SLionel Sambuc if (__n_move != 0) 29644684ddb6SLionel Sambuc traits_type::move(__p + __pos + __n2, __p + __pos + __n1, __n_move); 29654684ddb6SLionel Sambuc } 29664684ddb6SLionel Sambuc } 29674684ddb6SLionel Sambuc else 29684684ddb6SLionel Sambuc { 29694684ddb6SLionel Sambuc __grow_by(__cap, __sz - __n1 + __n2 - __cap, __sz, __pos, __n1, __n2); 29704684ddb6SLionel Sambuc __p = _VSTD::__to_raw_pointer(__get_long_pointer()); 29714684ddb6SLionel Sambuc } 29724684ddb6SLionel Sambuc traits_type::assign(__p + __pos, __n2, __c); 29734684ddb6SLionel Sambuc __sz += __n2 - __n1; 29744684ddb6SLionel Sambuc __set_size(__sz); 29754684ddb6SLionel Sambuc __invalidate_iterators_past(__sz); 29764684ddb6SLionel Sambuc traits_type::assign(__p[__sz], value_type()); 29774684ddb6SLionel Sambuc return *this; 29784684ddb6SLionel Sambuc} 29794684ddb6SLionel Sambuc 29804684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 29814684ddb6SLionel Sambuctemplate<class _InputIterator> 29824684ddb6SLionel Sambuctypename enable_if 29834684ddb6SLionel Sambuc< 29844684ddb6SLionel Sambuc __is_input_iterator<_InputIterator>::value, 29854684ddb6SLionel Sambuc basic_string<_CharT, _Traits, _Allocator>& 29864684ddb6SLionel Sambuc>::type 29874684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, 29884684ddb6SLionel Sambuc _InputIterator __j1, _InputIterator __j2) 29894684ddb6SLionel Sambuc{ 29904684ddb6SLionel Sambuc for (; true; ++__i1, ++__j1) 29914684ddb6SLionel Sambuc { 29924684ddb6SLionel Sambuc if (__i1 == __i2) 29934684ddb6SLionel Sambuc { 29944684ddb6SLionel Sambuc if (__j1 != __j2) 29954684ddb6SLionel Sambuc insert(__i1, __j1, __j2); 29964684ddb6SLionel Sambuc break; 29974684ddb6SLionel Sambuc } 29984684ddb6SLionel Sambuc if (__j1 == __j2) 29994684ddb6SLionel Sambuc { 30004684ddb6SLionel Sambuc erase(__i1, __i2); 30014684ddb6SLionel Sambuc break; 30024684ddb6SLionel Sambuc } 30034684ddb6SLionel Sambuc traits_type::assign(const_cast<value_type&>(*__i1), *__j1); 30044684ddb6SLionel Sambuc } 30054684ddb6SLionel Sambuc return *this; 30064684ddb6SLionel Sambuc} 30074684ddb6SLionel Sambuc 30084684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 30094684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 30104684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>& 30114684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const basic_string& __str) 30124684ddb6SLionel Sambuc{ 30134684ddb6SLionel Sambuc return replace(__pos1, __n1, __str.data(), __str.size()); 30144684ddb6SLionel Sambuc} 30154684ddb6SLionel Sambuc 30164684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 30174684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>& 30184684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const basic_string& __str, 30194684ddb6SLionel Sambuc size_type __pos2, size_type __n2) 30204684ddb6SLionel Sambuc{ 30214684ddb6SLionel Sambuc size_type __str_sz = __str.size(); 30224684ddb6SLionel Sambuc if (__pos2 > __str_sz) 30234684ddb6SLionel Sambuc this->__throw_out_of_range(); 30244684ddb6SLionel Sambuc return replace(__pos1, __n1, __str.data() + __pos2, _VSTD::min(__n2, __str_sz - __pos2)); 30254684ddb6SLionel Sambuc} 30264684ddb6SLionel Sambuc 30274684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 30284684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>& 30294684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s) 30304684ddb6SLionel Sambuc{ 3031*0a6a1f1dSLionel Sambuc _LIBCPP_ASSERT(__s != nullptr, "string::replace received nullptr"); 30324684ddb6SLionel Sambuc return replace(__pos, __n1, __s, traits_type::length(__s)); 30334684ddb6SLionel Sambuc} 30344684ddb6SLionel Sambuc 30354684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 30364684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 30374684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>& 30384684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const basic_string& __str) 30394684ddb6SLionel Sambuc{ 30404684ddb6SLionel Sambuc return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), 30414684ddb6SLionel Sambuc __str.data(), __str.size()); 30424684ddb6SLionel Sambuc} 30434684ddb6SLionel Sambuc 30444684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 30454684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 30464684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>& 30474684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n) 30484684ddb6SLionel Sambuc{ 30494684ddb6SLionel Sambuc return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), __s, __n); 30504684ddb6SLionel Sambuc} 30514684ddb6SLionel Sambuc 30524684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 30534684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 30544684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>& 30554684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const value_type* __s) 30564684ddb6SLionel Sambuc{ 30574684ddb6SLionel Sambuc return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), __s); 30584684ddb6SLionel Sambuc} 30594684ddb6SLionel Sambuc 30604684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 30614684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 30624684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>& 30634684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c) 30644684ddb6SLionel Sambuc{ 30654684ddb6SLionel Sambuc return replace(static_cast<size_type>(__i1 - begin()), static_cast<size_type>(__i2 - __i1), __n, __c); 30664684ddb6SLionel Sambuc} 30674684ddb6SLionel Sambuc 30684684ddb6SLionel Sambuc// erase 30694684ddb6SLionel Sambuc 30704684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 30714684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>& 30724684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos, size_type __n) 30734684ddb6SLionel Sambuc{ 30744684ddb6SLionel Sambuc size_type __sz = size(); 30754684ddb6SLionel Sambuc if (__pos > __sz) 30764684ddb6SLionel Sambuc this->__throw_out_of_range(); 30774684ddb6SLionel Sambuc if (__n) 30784684ddb6SLionel Sambuc { 30794684ddb6SLionel Sambuc value_type* __p = _VSTD::__to_raw_pointer(__get_pointer()); 30804684ddb6SLionel Sambuc __n = _VSTD::min(__n, __sz - __pos); 30814684ddb6SLionel Sambuc size_type __n_move = __sz - __pos - __n; 30824684ddb6SLionel Sambuc if (__n_move != 0) 30834684ddb6SLionel Sambuc traits_type::move(__p + __pos, __p + __pos + __n, __n_move); 30844684ddb6SLionel Sambuc __sz -= __n; 30854684ddb6SLionel Sambuc __set_size(__sz); 30864684ddb6SLionel Sambuc __invalidate_iterators_past(__sz); 30874684ddb6SLionel Sambuc traits_type::assign(__p[__sz], value_type()); 30884684ddb6SLionel Sambuc } 30894684ddb6SLionel Sambuc return *this; 30904684ddb6SLionel Sambuc} 30914684ddb6SLionel Sambuc 30924684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 30934684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 30944684ddb6SLionel Sambuctypename basic_string<_CharT, _Traits, _Allocator>::iterator 30954684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __pos) 30964684ddb6SLionel Sambuc{ 30974684ddb6SLionel Sambuc#if _LIBCPP_DEBUG_LEVEL >= 2 30984684ddb6SLionel Sambuc _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, 30994684ddb6SLionel Sambuc "string::erase(iterator) called with an iterator not" 31004684ddb6SLionel Sambuc " referring to this string"); 31014684ddb6SLionel Sambuc#endif 31024684ddb6SLionel Sambuc _LIBCPP_ASSERT(__pos != end(), 31034684ddb6SLionel Sambuc "string::erase(iterator) called with a non-dereferenceable iterator"); 31044684ddb6SLionel Sambuc iterator __b = begin(); 31054684ddb6SLionel Sambuc size_type __r = static_cast<size_type>(__pos - __b); 31064684ddb6SLionel Sambuc erase(__r, 1); 31074684ddb6SLionel Sambuc return __b + static_cast<difference_type>(__r); 31084684ddb6SLionel Sambuc} 31094684ddb6SLionel Sambuc 31104684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 31114684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 31124684ddb6SLionel Sambuctypename basic_string<_CharT, _Traits, _Allocator>::iterator 31134684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __first, const_iterator __last) 31144684ddb6SLionel Sambuc{ 31154684ddb6SLionel Sambuc#if _LIBCPP_DEBUG_LEVEL >= 2 31164684ddb6SLionel Sambuc _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this, 31174684ddb6SLionel Sambuc "string::erase(iterator, iterator) called with an iterator not" 31184684ddb6SLionel Sambuc " referring to this string"); 31194684ddb6SLionel Sambuc#endif 31204684ddb6SLionel Sambuc _LIBCPP_ASSERT(__first <= __last, "string::erase(first, last) called with invalid range"); 31214684ddb6SLionel Sambuc iterator __b = begin(); 31224684ddb6SLionel Sambuc size_type __r = static_cast<size_type>(__first - __b); 31234684ddb6SLionel Sambuc erase(__r, static_cast<size_type>(__last - __first)); 31244684ddb6SLionel Sambuc return __b + static_cast<difference_type>(__r); 31254684ddb6SLionel Sambuc} 31264684ddb6SLionel Sambuc 31274684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 31284684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 31294684ddb6SLionel Sambucvoid 31304684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::pop_back() 31314684ddb6SLionel Sambuc{ 31324684ddb6SLionel Sambuc _LIBCPP_ASSERT(!empty(), "string::pop_back(): string is already empty"); 31334684ddb6SLionel Sambuc size_type __sz; 31344684ddb6SLionel Sambuc if (__is_long()) 31354684ddb6SLionel Sambuc { 31364684ddb6SLionel Sambuc __sz = __get_long_size() - 1; 31374684ddb6SLionel Sambuc __set_long_size(__sz); 31384684ddb6SLionel Sambuc traits_type::assign(*(__get_long_pointer() + __sz), value_type()); 31394684ddb6SLionel Sambuc } 31404684ddb6SLionel Sambuc else 31414684ddb6SLionel Sambuc { 31424684ddb6SLionel Sambuc __sz = __get_short_size() - 1; 31434684ddb6SLionel Sambuc __set_short_size(__sz); 31444684ddb6SLionel Sambuc traits_type::assign(*(__get_short_pointer() + __sz), value_type()); 31454684ddb6SLionel Sambuc } 31464684ddb6SLionel Sambuc __invalidate_iterators_past(__sz); 31474684ddb6SLionel Sambuc} 31484684ddb6SLionel Sambuc 31494684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 31504684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 31514684ddb6SLionel Sambucvoid 31524684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::clear() _NOEXCEPT 31534684ddb6SLionel Sambuc{ 31544684ddb6SLionel Sambuc __invalidate_all_iterators(); 31554684ddb6SLionel Sambuc if (__is_long()) 31564684ddb6SLionel Sambuc { 31574684ddb6SLionel Sambuc traits_type::assign(*__get_long_pointer(), value_type()); 31584684ddb6SLionel Sambuc __set_long_size(0); 31594684ddb6SLionel Sambuc } 31604684ddb6SLionel Sambuc else 31614684ddb6SLionel Sambuc { 31624684ddb6SLionel Sambuc traits_type::assign(*__get_short_pointer(), value_type()); 31634684ddb6SLionel Sambuc __set_short_size(0); 31644684ddb6SLionel Sambuc } 31654684ddb6SLionel Sambuc} 31664684ddb6SLionel Sambuc 31674684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 31684684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 31694684ddb6SLionel Sambucvoid 31704684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::__erase_to_end(size_type __pos) 31714684ddb6SLionel Sambuc{ 31724684ddb6SLionel Sambuc if (__is_long()) 31734684ddb6SLionel Sambuc { 31744684ddb6SLionel Sambuc traits_type::assign(*(__get_long_pointer() + __pos), value_type()); 31754684ddb6SLionel Sambuc __set_long_size(__pos); 31764684ddb6SLionel Sambuc } 31774684ddb6SLionel Sambuc else 31784684ddb6SLionel Sambuc { 31794684ddb6SLionel Sambuc traits_type::assign(*(__get_short_pointer() + __pos), value_type()); 31804684ddb6SLionel Sambuc __set_short_size(__pos); 31814684ddb6SLionel Sambuc } 31824684ddb6SLionel Sambuc __invalidate_iterators_past(__pos); 31834684ddb6SLionel Sambuc} 31844684ddb6SLionel Sambuc 31854684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 31864684ddb6SLionel Sambucvoid 31874684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::resize(size_type __n, value_type __c) 31884684ddb6SLionel Sambuc{ 31894684ddb6SLionel Sambuc size_type __sz = size(); 31904684ddb6SLionel Sambuc if (__n > __sz) 31914684ddb6SLionel Sambuc append(__n - __sz, __c); 31924684ddb6SLionel Sambuc else 31934684ddb6SLionel Sambuc __erase_to_end(__n); 31944684ddb6SLionel Sambuc} 31954684ddb6SLionel Sambuc 31964684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 31974684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 31984684ddb6SLionel Sambuctypename basic_string<_CharT, _Traits, _Allocator>::size_type 31994684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::max_size() const _NOEXCEPT 32004684ddb6SLionel Sambuc{ 32014684ddb6SLionel Sambuc size_type __m = __alloc_traits::max_size(__alloc()); 32024684ddb6SLionel Sambuc#if _LIBCPP_BIG_ENDIAN 32034684ddb6SLionel Sambuc return (__m <= ~__long_mask ? __m : __m/2) - __alignment; 32044684ddb6SLionel Sambuc#else 32054684ddb6SLionel Sambuc return __m - __alignment; 32064684ddb6SLionel Sambuc#endif 32074684ddb6SLionel Sambuc} 32084684ddb6SLionel Sambuc 32094684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 32104684ddb6SLionel Sambucvoid 32114684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::reserve(size_type __res_arg) 32124684ddb6SLionel Sambuc{ 32134684ddb6SLionel Sambuc if (__res_arg > max_size()) 32144684ddb6SLionel Sambuc this->__throw_length_error(); 32154684ddb6SLionel Sambuc size_type __cap = capacity(); 32164684ddb6SLionel Sambuc size_type __sz = size(); 32174684ddb6SLionel Sambuc __res_arg = _VSTD::max(__res_arg, __sz); 32184684ddb6SLionel Sambuc __res_arg = __recommend(__res_arg); 32194684ddb6SLionel Sambuc if (__res_arg != __cap) 32204684ddb6SLionel Sambuc { 32214684ddb6SLionel Sambuc pointer __new_data, __p; 32224684ddb6SLionel Sambuc bool __was_long, __now_long; 32234684ddb6SLionel Sambuc if (__res_arg == __min_cap - 1) 32244684ddb6SLionel Sambuc { 32254684ddb6SLionel Sambuc __was_long = true; 32264684ddb6SLionel Sambuc __now_long = false; 32274684ddb6SLionel Sambuc __new_data = __get_short_pointer(); 32284684ddb6SLionel Sambuc __p = __get_long_pointer(); 32294684ddb6SLionel Sambuc } 32304684ddb6SLionel Sambuc else 32314684ddb6SLionel Sambuc { 32324684ddb6SLionel Sambuc if (__res_arg > __cap) 32334684ddb6SLionel Sambuc __new_data = __alloc_traits::allocate(__alloc(), __res_arg+1); 32344684ddb6SLionel Sambuc else 32354684ddb6SLionel Sambuc { 32364684ddb6SLionel Sambuc #ifndef _LIBCPP_NO_EXCEPTIONS 32374684ddb6SLionel Sambuc try 32384684ddb6SLionel Sambuc { 32394684ddb6SLionel Sambuc #endif // _LIBCPP_NO_EXCEPTIONS 32404684ddb6SLionel Sambuc __new_data = __alloc_traits::allocate(__alloc(), __res_arg+1); 32414684ddb6SLionel Sambuc #ifndef _LIBCPP_NO_EXCEPTIONS 32424684ddb6SLionel Sambuc } 32434684ddb6SLionel Sambuc catch (...) 32444684ddb6SLionel Sambuc { 32454684ddb6SLionel Sambuc return; 32464684ddb6SLionel Sambuc } 32474684ddb6SLionel Sambuc #else // _LIBCPP_NO_EXCEPTIONS 32484684ddb6SLionel Sambuc if (__new_data == nullptr) 32494684ddb6SLionel Sambuc return; 32504684ddb6SLionel Sambuc #endif // _LIBCPP_NO_EXCEPTIONS 32514684ddb6SLionel Sambuc } 32524684ddb6SLionel Sambuc __now_long = true; 32534684ddb6SLionel Sambuc __was_long = __is_long(); 32544684ddb6SLionel Sambuc __p = __get_pointer(); 32554684ddb6SLionel Sambuc } 32564684ddb6SLionel Sambuc traits_type::copy(_VSTD::__to_raw_pointer(__new_data), 32574684ddb6SLionel Sambuc _VSTD::__to_raw_pointer(__p), size()+1); 32584684ddb6SLionel Sambuc if (__was_long) 32594684ddb6SLionel Sambuc __alloc_traits::deallocate(__alloc(), __p, __cap+1); 32604684ddb6SLionel Sambuc if (__now_long) 32614684ddb6SLionel Sambuc { 32624684ddb6SLionel Sambuc __set_long_cap(__res_arg+1); 32634684ddb6SLionel Sambuc __set_long_size(__sz); 32644684ddb6SLionel Sambuc __set_long_pointer(__new_data); 32654684ddb6SLionel Sambuc } 32664684ddb6SLionel Sambuc else 32674684ddb6SLionel Sambuc __set_short_size(__sz); 32684684ddb6SLionel Sambuc __invalidate_all_iterators(); 32694684ddb6SLionel Sambuc } 32704684ddb6SLionel Sambuc} 32714684ddb6SLionel Sambuc 32724684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 32734684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 32744684ddb6SLionel Sambuctypename basic_string<_CharT, _Traits, _Allocator>::const_reference 32754684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) const 32764684ddb6SLionel Sambuc{ 32774684ddb6SLionel Sambuc _LIBCPP_ASSERT(__pos <= size(), "string index out of bounds"); 32784684ddb6SLionel Sambuc return *(data() + __pos); 32794684ddb6SLionel Sambuc} 32804684ddb6SLionel Sambuc 32814684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 32824684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 32834684ddb6SLionel Sambuctypename basic_string<_CharT, _Traits, _Allocator>::reference 32844684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) 32854684ddb6SLionel Sambuc{ 32864684ddb6SLionel Sambuc _LIBCPP_ASSERT(__pos <= size(), "string index out of bounds"); 32874684ddb6SLionel Sambuc return *(__get_pointer() + __pos); 32884684ddb6SLionel Sambuc} 32894684ddb6SLionel Sambuc 32904684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 32914684ddb6SLionel Sambuctypename basic_string<_CharT, _Traits, _Allocator>::const_reference 32924684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::at(size_type __n) const 32934684ddb6SLionel Sambuc{ 32944684ddb6SLionel Sambuc if (__n >= size()) 32954684ddb6SLionel Sambuc this->__throw_out_of_range(); 32964684ddb6SLionel Sambuc return (*this)[__n]; 32974684ddb6SLionel Sambuc} 32984684ddb6SLionel Sambuc 32994684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 33004684ddb6SLionel Sambuctypename basic_string<_CharT, _Traits, _Allocator>::reference 33014684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::at(size_type __n) 33024684ddb6SLionel Sambuc{ 33034684ddb6SLionel Sambuc if (__n >= size()) 33044684ddb6SLionel Sambuc this->__throw_out_of_range(); 33054684ddb6SLionel Sambuc return (*this)[__n]; 33064684ddb6SLionel Sambuc} 33074684ddb6SLionel Sambuc 33084684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 33094684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 33104684ddb6SLionel Sambuctypename basic_string<_CharT, _Traits, _Allocator>::reference 33114684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::front() 33124684ddb6SLionel Sambuc{ 33134684ddb6SLionel Sambuc _LIBCPP_ASSERT(!empty(), "string::front(): string is empty"); 33144684ddb6SLionel Sambuc return *__get_pointer(); 33154684ddb6SLionel Sambuc} 33164684ddb6SLionel Sambuc 33174684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 33184684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 33194684ddb6SLionel Sambuctypename basic_string<_CharT, _Traits, _Allocator>::const_reference 33204684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::front() const 33214684ddb6SLionel Sambuc{ 33224684ddb6SLionel Sambuc _LIBCPP_ASSERT(!empty(), "string::front(): string is empty"); 33234684ddb6SLionel Sambuc return *data(); 33244684ddb6SLionel Sambuc} 33254684ddb6SLionel Sambuc 33264684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 33274684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 33284684ddb6SLionel Sambuctypename basic_string<_CharT, _Traits, _Allocator>::reference 33294684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::back() 33304684ddb6SLionel Sambuc{ 33314684ddb6SLionel Sambuc _LIBCPP_ASSERT(!empty(), "string::back(): string is empty"); 33324684ddb6SLionel Sambuc return *(__get_pointer() + size() - 1); 33334684ddb6SLionel Sambuc} 33344684ddb6SLionel Sambuc 33354684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 33364684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 33374684ddb6SLionel Sambuctypename basic_string<_CharT, _Traits, _Allocator>::const_reference 33384684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::back() const 33394684ddb6SLionel Sambuc{ 33404684ddb6SLionel Sambuc _LIBCPP_ASSERT(!empty(), "string::back(): string is empty"); 33414684ddb6SLionel Sambuc return *(data() + size() - 1); 33424684ddb6SLionel Sambuc} 33434684ddb6SLionel Sambuc 33444684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 33454684ddb6SLionel Sambuctypename basic_string<_CharT, _Traits, _Allocator>::size_type 33464684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::copy(value_type* __s, size_type __n, size_type __pos) const 33474684ddb6SLionel Sambuc{ 33484684ddb6SLionel Sambuc size_type __sz = size(); 33494684ddb6SLionel Sambuc if (__pos > __sz) 33504684ddb6SLionel Sambuc this->__throw_out_of_range(); 33514684ddb6SLionel Sambuc size_type __rlen = _VSTD::min(__n, __sz - __pos); 33524684ddb6SLionel Sambuc traits_type::copy(__s, data() + __pos, __rlen); 33534684ddb6SLionel Sambuc return __rlen; 33544684ddb6SLionel Sambuc} 33554684ddb6SLionel Sambuc 33564684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 33574684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 33584684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator> 33594684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::substr(size_type __pos, size_type __n) const 33604684ddb6SLionel Sambuc{ 33614684ddb6SLionel Sambuc return basic_string(*this, __pos, __n, __alloc()); 33624684ddb6SLionel Sambuc} 33634684ddb6SLionel Sambuc 33644684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 33654684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 33664684ddb6SLionel Sambucvoid 33674684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str) 3368*0a6a1f1dSLionel Sambuc#if _LIBCPP_STD_VER >= 14 3369*0a6a1f1dSLionel Sambuc _NOEXCEPT 3370*0a6a1f1dSLionel Sambuc#else 33714684ddb6SLionel Sambuc _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || 33724684ddb6SLionel Sambuc __is_nothrow_swappable<allocator_type>::value) 3373*0a6a1f1dSLionel Sambuc#endif 33744684ddb6SLionel Sambuc{ 33754684ddb6SLionel Sambuc#if _LIBCPP_DEBUG_LEVEL >= 2 33764684ddb6SLionel Sambuc if (!__is_long()) 33774684ddb6SLionel Sambuc __get_db()->__invalidate_all(this); 33784684ddb6SLionel Sambuc if (!__str.__is_long()) 33794684ddb6SLionel Sambuc __get_db()->__invalidate_all(&__str); 33804684ddb6SLionel Sambuc __get_db()->swap(this, &__str); 33814684ddb6SLionel Sambuc#endif 33824684ddb6SLionel Sambuc _VSTD::swap(__r_.first(), __str.__r_.first()); 3383*0a6a1f1dSLionel Sambuc __swap_allocator(__alloc(), __str.__alloc()); 33844684ddb6SLionel Sambuc} 33854684ddb6SLionel Sambuc 33864684ddb6SLionel Sambuc// find 33874684ddb6SLionel Sambuc 33884684ddb6SLionel Sambuctemplate <class _Traits> 33894684ddb6SLionel Sambucstruct _LIBCPP_HIDDEN __traits_eq 33904684ddb6SLionel Sambuc{ 33914684ddb6SLionel Sambuc typedef typename _Traits::char_type char_type; 33924684ddb6SLionel Sambuc _LIBCPP_INLINE_VISIBILITY 33934684ddb6SLionel Sambuc bool operator()(const char_type& __x, const char_type& __y) _NOEXCEPT 33944684ddb6SLionel Sambuc {return _Traits::eq(__x, __y);} 33954684ddb6SLionel Sambuc}; 33964684ddb6SLionel Sambuc 33974684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 33984684ddb6SLionel Sambuctypename basic_string<_CharT, _Traits, _Allocator>::size_type 33994684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, 34004684ddb6SLionel Sambuc size_type __pos, 34014684ddb6SLionel Sambuc size_type __n) const _NOEXCEPT 34024684ddb6SLionel Sambuc{ 3403*0a6a1f1dSLionel Sambuc _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find(): received nullptr"); 3404*0a6a1f1dSLionel Sambuc return _VSTD::__str_find<value_type, size_type, traits_type, npos> 3405*0a6a1f1dSLionel Sambuc (data(), size(), __s, __pos, __n); 34064684ddb6SLionel Sambuc} 34074684ddb6SLionel Sambuc 34084684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 34094684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 34104684ddb6SLionel Sambuctypename basic_string<_CharT, _Traits, _Allocator>::size_type 34114684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::find(const basic_string& __str, 34124684ddb6SLionel Sambuc size_type __pos) const _NOEXCEPT 34134684ddb6SLionel Sambuc{ 3414*0a6a1f1dSLionel Sambuc return _VSTD::__str_find<value_type, size_type, traits_type, npos> 3415*0a6a1f1dSLionel Sambuc (data(), size(), __str.data(), __pos, __str.size()); 34164684ddb6SLionel Sambuc} 34174684ddb6SLionel Sambuc 34184684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 34194684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 34204684ddb6SLionel Sambuctypename basic_string<_CharT, _Traits, _Allocator>::size_type 34214684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, 34224684ddb6SLionel Sambuc size_type __pos) const _NOEXCEPT 34234684ddb6SLionel Sambuc{ 3424*0a6a1f1dSLionel Sambuc _LIBCPP_ASSERT(__s != nullptr, "string::find(): received nullptr"); 3425*0a6a1f1dSLionel Sambuc return _VSTD::__str_find<value_type, size_type, traits_type, npos> 3426*0a6a1f1dSLionel Sambuc (data(), size(), __s, __pos, traits_type::length(__s)); 34274684ddb6SLionel Sambuc} 34284684ddb6SLionel Sambuc 34294684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 34304684ddb6SLionel Sambuctypename basic_string<_CharT, _Traits, _Allocator>::size_type 34314684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::find(value_type __c, 34324684ddb6SLionel Sambuc size_type __pos) const _NOEXCEPT 34334684ddb6SLionel Sambuc{ 3434*0a6a1f1dSLionel Sambuc return _VSTD::__str_find<value_type, size_type, traits_type, npos> 3435*0a6a1f1dSLionel Sambuc (data(), size(), __c, __pos); 34364684ddb6SLionel Sambuc} 34374684ddb6SLionel Sambuc 34384684ddb6SLionel Sambuc// rfind 34394684ddb6SLionel Sambuc 34404684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 34414684ddb6SLionel Sambuctypename basic_string<_CharT, _Traits, _Allocator>::size_type 34424684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s, 34434684ddb6SLionel Sambuc size_type __pos, 34444684ddb6SLionel Sambuc size_type __n) const _NOEXCEPT 34454684ddb6SLionel Sambuc{ 3446*0a6a1f1dSLionel Sambuc _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::rfind(): received nullptr"); 3447*0a6a1f1dSLionel Sambuc return _VSTD::__str_rfind<value_type, size_type, traits_type, npos> 3448*0a6a1f1dSLionel Sambuc (data(), size(), __s, __pos, __n); 34494684ddb6SLionel Sambuc} 34504684ddb6SLionel Sambuc 34514684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 34524684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 34534684ddb6SLionel Sambuctypename basic_string<_CharT, _Traits, _Allocator>::size_type 34544684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::rfind(const basic_string& __str, 34554684ddb6SLionel Sambuc size_type __pos) const _NOEXCEPT 34564684ddb6SLionel Sambuc{ 3457*0a6a1f1dSLionel Sambuc return _VSTD::__str_rfind<value_type, size_type, traits_type, npos> 3458*0a6a1f1dSLionel Sambuc (data(), size(), __str.data(), __pos, __str.size()); 34594684ddb6SLionel Sambuc} 34604684ddb6SLionel Sambuc 34614684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 34624684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 34634684ddb6SLionel Sambuctypename basic_string<_CharT, _Traits, _Allocator>::size_type 34644684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s, 34654684ddb6SLionel Sambuc size_type __pos) const _NOEXCEPT 34664684ddb6SLionel Sambuc{ 3467*0a6a1f1dSLionel Sambuc _LIBCPP_ASSERT(__s != nullptr, "string::rfind(): received nullptr"); 3468*0a6a1f1dSLionel Sambuc return _VSTD::__str_rfind<value_type, size_type, traits_type, npos> 3469*0a6a1f1dSLionel Sambuc (data(), size(), __s, __pos, traits_type::length(__s)); 34704684ddb6SLionel Sambuc} 34714684ddb6SLionel Sambuc 34724684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 34734684ddb6SLionel Sambuctypename basic_string<_CharT, _Traits, _Allocator>::size_type 34744684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::rfind(value_type __c, 34754684ddb6SLionel Sambuc size_type __pos) const _NOEXCEPT 34764684ddb6SLionel Sambuc{ 3477*0a6a1f1dSLionel Sambuc return _VSTD::__str_rfind<value_type, size_type, traits_type, npos> 3478*0a6a1f1dSLionel Sambuc (data(), size(), __c, __pos); 34794684ddb6SLionel Sambuc} 34804684ddb6SLionel Sambuc 34814684ddb6SLionel Sambuc// find_first_of 34824684ddb6SLionel Sambuc 34834684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 34844684ddb6SLionel Sambuctypename basic_string<_CharT, _Traits, _Allocator>::size_type 34854684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s, 34864684ddb6SLionel Sambuc size_type __pos, 34874684ddb6SLionel Sambuc size_type __n) const _NOEXCEPT 34884684ddb6SLionel Sambuc{ 3489*0a6a1f1dSLionel Sambuc _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_of(): received nullptr"); 3490*0a6a1f1dSLionel Sambuc return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos> 3491*0a6a1f1dSLionel Sambuc (data(), size(), __s, __pos, __n); 34924684ddb6SLionel Sambuc} 34934684ddb6SLionel Sambuc 34944684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 34954684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 34964684ddb6SLionel Sambuctypename basic_string<_CharT, _Traits, _Allocator>::size_type 34974684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::find_first_of(const basic_string& __str, 34984684ddb6SLionel Sambuc size_type __pos) const _NOEXCEPT 34994684ddb6SLionel Sambuc{ 3500*0a6a1f1dSLionel Sambuc return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos> 3501*0a6a1f1dSLionel Sambuc (data(), size(), __str.data(), __pos, __str.size()); 35024684ddb6SLionel Sambuc} 35034684ddb6SLionel Sambuc 35044684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 35054684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 35064684ddb6SLionel Sambuctypename basic_string<_CharT, _Traits, _Allocator>::size_type 35074684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s, 35084684ddb6SLionel Sambuc size_type __pos) const _NOEXCEPT 35094684ddb6SLionel Sambuc{ 3510*0a6a1f1dSLionel Sambuc _LIBCPP_ASSERT(__s != nullptr, "string::find_first_of(): received nullptr"); 3511*0a6a1f1dSLionel Sambuc return _VSTD::__str_find_first_of<value_type, size_type, traits_type, npos> 3512*0a6a1f1dSLionel Sambuc (data(), size(), __s, __pos, traits_type::length(__s)); 35134684ddb6SLionel Sambuc} 35144684ddb6SLionel Sambuc 35154684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 35164684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 35174684ddb6SLionel Sambuctypename basic_string<_CharT, _Traits, _Allocator>::size_type 35184684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::find_first_of(value_type __c, 35194684ddb6SLionel Sambuc size_type __pos) const _NOEXCEPT 35204684ddb6SLionel Sambuc{ 35214684ddb6SLionel Sambuc return find(__c, __pos); 35224684ddb6SLionel Sambuc} 35234684ddb6SLionel Sambuc 35244684ddb6SLionel Sambuc// find_last_of 35254684ddb6SLionel Sambuc 35264684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 35274684ddb6SLionel Sambuctypename basic_string<_CharT, _Traits, _Allocator>::size_type 35284684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s, 35294684ddb6SLionel Sambuc size_type __pos, 35304684ddb6SLionel Sambuc size_type __n) const _NOEXCEPT 35314684ddb6SLionel Sambuc{ 3532*0a6a1f1dSLionel Sambuc _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_of(): received nullptr"); 3533*0a6a1f1dSLionel Sambuc return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos> 3534*0a6a1f1dSLionel Sambuc (data(), size(), __s, __pos, __n); 35354684ddb6SLionel Sambuc} 35364684ddb6SLionel Sambuc 35374684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 35384684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 35394684ddb6SLionel Sambuctypename basic_string<_CharT, _Traits, _Allocator>::size_type 35404684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::find_last_of(const basic_string& __str, 35414684ddb6SLionel Sambuc size_type __pos) const _NOEXCEPT 35424684ddb6SLionel Sambuc{ 3543*0a6a1f1dSLionel Sambuc return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos> 3544*0a6a1f1dSLionel Sambuc (data(), size(), __str.data(), __pos, __str.size()); 35454684ddb6SLionel Sambuc} 35464684ddb6SLionel Sambuc 35474684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 35484684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 35494684ddb6SLionel Sambuctypename basic_string<_CharT, _Traits, _Allocator>::size_type 35504684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s, 35514684ddb6SLionel Sambuc size_type __pos) const _NOEXCEPT 35524684ddb6SLionel Sambuc{ 3553*0a6a1f1dSLionel Sambuc _LIBCPP_ASSERT(__s != nullptr, "string::find_last_of(): received nullptr"); 3554*0a6a1f1dSLionel Sambuc return _VSTD::__str_find_last_of<value_type, size_type, traits_type, npos> 3555*0a6a1f1dSLionel Sambuc (data(), size(), __s, __pos, traits_type::length(__s)); 35564684ddb6SLionel Sambuc} 35574684ddb6SLionel Sambuc 35584684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 35594684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 35604684ddb6SLionel Sambuctypename basic_string<_CharT, _Traits, _Allocator>::size_type 35614684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::find_last_of(value_type __c, 35624684ddb6SLionel Sambuc size_type __pos) const _NOEXCEPT 35634684ddb6SLionel Sambuc{ 35644684ddb6SLionel Sambuc return rfind(__c, __pos); 35654684ddb6SLionel Sambuc} 35664684ddb6SLionel Sambuc 35674684ddb6SLionel Sambuc// find_first_not_of 35684684ddb6SLionel Sambuc 35694684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 35704684ddb6SLionel Sambuctypename basic_string<_CharT, _Traits, _Allocator>::size_type 35714684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s, 35724684ddb6SLionel Sambuc size_type __pos, 35734684ddb6SLionel Sambuc size_type __n) const _NOEXCEPT 35744684ddb6SLionel Sambuc{ 3575*0a6a1f1dSLionel Sambuc _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_not_of(): received nullptr"); 3576*0a6a1f1dSLionel Sambuc return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos> 3577*0a6a1f1dSLionel Sambuc (data(), size(), __s, __pos, __n); 35784684ddb6SLionel Sambuc} 35794684ddb6SLionel Sambuc 35804684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 35814684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 35824684ddb6SLionel Sambuctypename basic_string<_CharT, _Traits, _Allocator>::size_type 35834684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const basic_string& __str, 35844684ddb6SLionel Sambuc size_type __pos) const _NOEXCEPT 35854684ddb6SLionel Sambuc{ 3586*0a6a1f1dSLionel Sambuc return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos> 3587*0a6a1f1dSLionel Sambuc (data(), size(), __str.data(), __pos, __str.size()); 35884684ddb6SLionel Sambuc} 35894684ddb6SLionel Sambuc 35904684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 35914684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 35924684ddb6SLionel Sambuctypename basic_string<_CharT, _Traits, _Allocator>::size_type 35934684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s, 35944684ddb6SLionel Sambuc size_type __pos) const _NOEXCEPT 35954684ddb6SLionel Sambuc{ 3596*0a6a1f1dSLionel Sambuc _LIBCPP_ASSERT(__s != nullptr, "string::find_first_not_of(): received nullptr"); 3597*0a6a1f1dSLionel Sambuc return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos> 3598*0a6a1f1dSLionel Sambuc (data(), size(), __s, __pos, traits_type::length(__s)); 35994684ddb6SLionel Sambuc} 36004684ddb6SLionel Sambuc 36014684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 36024684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 36034684ddb6SLionel Sambuctypename basic_string<_CharT, _Traits, _Allocator>::size_type 36044684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::find_first_not_of(value_type __c, 36054684ddb6SLionel Sambuc size_type __pos) const _NOEXCEPT 36064684ddb6SLionel Sambuc{ 3607*0a6a1f1dSLionel Sambuc return _VSTD::__str_find_first_not_of<value_type, size_type, traits_type, npos> 3608*0a6a1f1dSLionel Sambuc (data(), size(), __c, __pos); 36094684ddb6SLionel Sambuc} 36104684ddb6SLionel Sambuc 36114684ddb6SLionel Sambuc// find_last_not_of 36124684ddb6SLionel Sambuc 36134684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 36144684ddb6SLionel Sambuctypename basic_string<_CharT, _Traits, _Allocator>::size_type 36154684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s, 36164684ddb6SLionel Sambuc size_type __pos, 36174684ddb6SLionel Sambuc size_type __n) const _NOEXCEPT 36184684ddb6SLionel Sambuc{ 3619*0a6a1f1dSLionel Sambuc _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_not_of(): received nullptr"); 3620*0a6a1f1dSLionel Sambuc return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos> 3621*0a6a1f1dSLionel Sambuc (data(), size(), __s, __pos, __n); 36224684ddb6SLionel Sambuc} 36234684ddb6SLionel Sambuc 36244684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 36254684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 36264684ddb6SLionel Sambuctypename basic_string<_CharT, _Traits, _Allocator>::size_type 36274684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const basic_string& __str, 36284684ddb6SLionel Sambuc size_type __pos) const _NOEXCEPT 36294684ddb6SLionel Sambuc{ 3630*0a6a1f1dSLionel Sambuc return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos> 3631*0a6a1f1dSLionel Sambuc (data(), size(), __str.data(), __pos, __str.size()); 36324684ddb6SLionel Sambuc} 36334684ddb6SLionel Sambuc 36344684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 36354684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 36364684ddb6SLionel Sambuctypename basic_string<_CharT, _Traits, _Allocator>::size_type 36374684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s, 36384684ddb6SLionel Sambuc size_type __pos) const _NOEXCEPT 36394684ddb6SLionel Sambuc{ 3640*0a6a1f1dSLionel Sambuc _LIBCPP_ASSERT(__s != nullptr, "string::find_last_not_of(): received nullptr"); 3641*0a6a1f1dSLionel Sambuc return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos> 3642*0a6a1f1dSLionel Sambuc (data(), size(), __s, __pos, traits_type::length(__s)); 36434684ddb6SLionel Sambuc} 36444684ddb6SLionel Sambuc 36454684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 36464684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 36474684ddb6SLionel Sambuctypename basic_string<_CharT, _Traits, _Allocator>::size_type 36484684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c, 36494684ddb6SLionel Sambuc size_type __pos) const _NOEXCEPT 36504684ddb6SLionel Sambuc{ 3651*0a6a1f1dSLionel Sambuc return _VSTD::__str_find_last_not_of<value_type, size_type, traits_type, npos> 3652*0a6a1f1dSLionel Sambuc (data(), size(), __c, __pos); 36534684ddb6SLionel Sambuc} 36544684ddb6SLionel Sambuc 36554684ddb6SLionel Sambuc// compare 36564684ddb6SLionel Sambuc 36574684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 36584684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 36594684ddb6SLionel Sambucint 36604684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::compare(const basic_string& __str) const _NOEXCEPT 36614684ddb6SLionel Sambuc{ 36624684ddb6SLionel Sambuc size_t __lhs_sz = size(); 36634684ddb6SLionel Sambuc size_t __rhs_sz = __str.size(); 36644684ddb6SLionel Sambuc int __result = traits_type::compare(data(), __str.data(), 36654684ddb6SLionel Sambuc _VSTD::min(__lhs_sz, __rhs_sz)); 36664684ddb6SLionel Sambuc if (__result != 0) 36674684ddb6SLionel Sambuc return __result; 36684684ddb6SLionel Sambuc if (__lhs_sz < __rhs_sz) 36694684ddb6SLionel Sambuc return -1; 36704684ddb6SLionel Sambuc if (__lhs_sz > __rhs_sz) 36714684ddb6SLionel Sambuc return 1; 36724684ddb6SLionel Sambuc return 0; 36734684ddb6SLionel Sambuc} 36744684ddb6SLionel Sambuc 36754684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 36764684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 36774684ddb6SLionel Sambucint 36784684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, 36794684ddb6SLionel Sambuc size_type __n1, 36804684ddb6SLionel Sambuc const basic_string& __str) const 36814684ddb6SLionel Sambuc{ 36824684ddb6SLionel Sambuc return compare(__pos1, __n1, __str.data(), __str.size()); 36834684ddb6SLionel Sambuc} 36844684ddb6SLionel Sambuc 36854684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 36864684ddb6SLionel Sambucint 36874684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, 36884684ddb6SLionel Sambuc size_type __n1, 36894684ddb6SLionel Sambuc const basic_string& __str, 36904684ddb6SLionel Sambuc size_type __pos2, 36914684ddb6SLionel Sambuc size_type __n2) const 36924684ddb6SLionel Sambuc{ 36934684ddb6SLionel Sambuc size_type __sz = __str.size(); 36944684ddb6SLionel Sambuc if (__pos2 > __sz) 36954684ddb6SLionel Sambuc this->__throw_out_of_range(); 36964684ddb6SLionel Sambuc return compare(__pos1, __n1, __str.data() + __pos2, _VSTD::min(__n2, 36974684ddb6SLionel Sambuc __sz - __pos2)); 36984684ddb6SLionel Sambuc} 36994684ddb6SLionel Sambuc 37004684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 37014684ddb6SLionel Sambucint 37024684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::compare(const value_type* __s) const _NOEXCEPT 37034684ddb6SLionel Sambuc{ 3704*0a6a1f1dSLionel Sambuc _LIBCPP_ASSERT(__s != nullptr, "string::compare(): received nullptr"); 37054684ddb6SLionel Sambuc return compare(0, npos, __s, traits_type::length(__s)); 37064684ddb6SLionel Sambuc} 37074684ddb6SLionel Sambuc 37084684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 37094684ddb6SLionel Sambucint 37104684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, 37114684ddb6SLionel Sambuc size_type __n1, 37124684ddb6SLionel Sambuc const value_type* __s) const 37134684ddb6SLionel Sambuc{ 3714*0a6a1f1dSLionel Sambuc _LIBCPP_ASSERT(__s != nullptr, "string::compare(): received nullptr"); 37154684ddb6SLionel Sambuc return compare(__pos1, __n1, __s, traits_type::length(__s)); 37164684ddb6SLionel Sambuc} 37174684ddb6SLionel Sambuc 37184684ddb6SLionel Sambuctemplate <class _CharT, class _Traits, class _Allocator> 37194684ddb6SLionel Sambucint 37204684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, 37214684ddb6SLionel Sambuc size_type __n1, 37224684ddb6SLionel Sambuc const value_type* __s, 37234684ddb6SLionel Sambuc size_type __n2) const 37244684ddb6SLionel Sambuc{ 3725*0a6a1f1dSLionel Sambuc _LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::compare(): received nullptr"); 37264684ddb6SLionel Sambuc size_type __sz = size(); 37274684ddb6SLionel Sambuc if (__pos1 > __sz || __n2 == npos) 37284684ddb6SLionel Sambuc this->__throw_out_of_range(); 37294684ddb6SLionel Sambuc size_type __rlen = _VSTD::min(__n1, __sz - __pos1); 37304684ddb6SLionel Sambuc int __r = traits_type::compare(data() + __pos1, __s, _VSTD::min(__rlen, __n2)); 37314684ddb6SLionel Sambuc if (__r == 0) 37324684ddb6SLionel Sambuc { 37334684ddb6SLionel Sambuc if (__rlen < __n2) 37344684ddb6SLionel Sambuc __r = -1; 37354684ddb6SLionel Sambuc else if (__rlen > __n2) 37364684ddb6SLionel Sambuc __r = 1; 37374684ddb6SLionel Sambuc } 37384684ddb6SLionel Sambuc return __r; 37394684ddb6SLionel Sambuc} 37404684ddb6SLionel Sambuc 37414684ddb6SLionel Sambuc// __invariants 37424684ddb6SLionel Sambuc 37434684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 37444684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 37454684ddb6SLionel Sambucbool 37464684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::__invariants() const 37474684ddb6SLionel Sambuc{ 37484684ddb6SLionel Sambuc if (size() > capacity()) 37494684ddb6SLionel Sambuc return false; 37504684ddb6SLionel Sambuc if (capacity() < __min_cap - 1) 37514684ddb6SLionel Sambuc return false; 37524684ddb6SLionel Sambuc if (data() == 0) 37534684ddb6SLionel Sambuc return false; 37544684ddb6SLionel Sambuc if (data()[size()] != value_type(0)) 37554684ddb6SLionel Sambuc return false; 37564684ddb6SLionel Sambuc return true; 37574684ddb6SLionel Sambuc} 37584684ddb6SLionel Sambuc 37594684ddb6SLionel Sambuc// operator== 37604684ddb6SLionel Sambuc 37614684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 37624684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 37634684ddb6SLionel Sambucbool 37644684ddb6SLionel Sambucoperator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs, 37654684ddb6SLionel Sambuc const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT 37664684ddb6SLionel Sambuc{ 37674684ddb6SLionel Sambuc size_t __lhs_sz = __lhs.size(); 37684684ddb6SLionel Sambuc return __lhs_sz == __rhs.size() && _Traits::compare(__lhs.data(), 37694684ddb6SLionel Sambuc __rhs.data(), 37704684ddb6SLionel Sambuc __lhs_sz) == 0; 37714684ddb6SLionel Sambuc} 37724684ddb6SLionel Sambuc 37734684ddb6SLionel Sambuctemplate<class _Allocator> 37744684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 37754684ddb6SLionel Sambucbool 37764684ddb6SLionel Sambucoperator==(const basic_string<char, char_traits<char>, _Allocator>& __lhs, 37774684ddb6SLionel Sambuc const basic_string<char, char_traits<char>, _Allocator>& __rhs) _NOEXCEPT 37784684ddb6SLionel Sambuc{ 37794684ddb6SLionel Sambuc size_t __lhs_sz = __lhs.size(); 37804684ddb6SLionel Sambuc if (__lhs_sz != __rhs.size()) 37814684ddb6SLionel Sambuc return false; 37824684ddb6SLionel Sambuc const char* __lp = __lhs.data(); 37834684ddb6SLionel Sambuc const char* __rp = __rhs.data(); 37844684ddb6SLionel Sambuc if (__lhs.__is_long()) 37854684ddb6SLionel Sambuc return char_traits<char>::compare(__lp, __rp, __lhs_sz) == 0; 37864684ddb6SLionel Sambuc for (; __lhs_sz != 0; --__lhs_sz, ++__lp, ++__rp) 37874684ddb6SLionel Sambuc if (*__lp != *__rp) 37884684ddb6SLionel Sambuc return false; 37894684ddb6SLionel Sambuc return true; 37904684ddb6SLionel Sambuc} 37914684ddb6SLionel Sambuc 37924684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 37934684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 37944684ddb6SLionel Sambucbool 37954684ddb6SLionel Sambucoperator==(const _CharT* __lhs, 37964684ddb6SLionel Sambuc const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT 37974684ddb6SLionel Sambuc{ 37984684ddb6SLionel Sambuc return __rhs.compare(__lhs) == 0; 37994684ddb6SLionel Sambuc} 38004684ddb6SLionel Sambuc 38014684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 38024684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 38034684ddb6SLionel Sambucbool 38044684ddb6SLionel Sambucoperator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs, 38054684ddb6SLionel Sambuc const _CharT* __rhs) _NOEXCEPT 38064684ddb6SLionel Sambuc{ 38074684ddb6SLionel Sambuc return __lhs.compare(__rhs) == 0; 38084684ddb6SLionel Sambuc} 38094684ddb6SLionel Sambuc 38104684ddb6SLionel Sambuc// operator!= 38114684ddb6SLionel Sambuc 38124684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 38134684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 38144684ddb6SLionel Sambucbool 38154684ddb6SLionel Sambucoperator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs, 38164684ddb6SLionel Sambuc const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT 38174684ddb6SLionel Sambuc{ 38184684ddb6SLionel Sambuc return !(__lhs == __rhs); 38194684ddb6SLionel Sambuc} 38204684ddb6SLionel Sambuc 38214684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 38224684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 38234684ddb6SLionel Sambucbool 38244684ddb6SLionel Sambucoperator!=(const _CharT* __lhs, 38254684ddb6SLionel Sambuc const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT 38264684ddb6SLionel Sambuc{ 38274684ddb6SLionel Sambuc return !(__lhs == __rhs); 38284684ddb6SLionel Sambuc} 38294684ddb6SLionel Sambuc 38304684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 38314684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 38324684ddb6SLionel Sambucbool 38334684ddb6SLionel Sambucoperator!=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, 38344684ddb6SLionel Sambuc const _CharT* __rhs) _NOEXCEPT 38354684ddb6SLionel Sambuc{ 38364684ddb6SLionel Sambuc return !(__lhs == __rhs); 38374684ddb6SLionel Sambuc} 38384684ddb6SLionel Sambuc 38394684ddb6SLionel Sambuc// operator< 38404684ddb6SLionel Sambuc 38414684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 38424684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 38434684ddb6SLionel Sambucbool 38444684ddb6SLionel Sambucoperator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs, 38454684ddb6SLionel Sambuc const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT 38464684ddb6SLionel Sambuc{ 38474684ddb6SLionel Sambuc return __lhs.compare(__rhs) < 0; 38484684ddb6SLionel Sambuc} 38494684ddb6SLionel Sambuc 38504684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 38514684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 38524684ddb6SLionel Sambucbool 38534684ddb6SLionel Sambucoperator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs, 38544684ddb6SLionel Sambuc const _CharT* __rhs) _NOEXCEPT 38554684ddb6SLionel Sambuc{ 38564684ddb6SLionel Sambuc return __lhs.compare(__rhs) < 0; 38574684ddb6SLionel Sambuc} 38584684ddb6SLionel Sambuc 38594684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 38604684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 38614684ddb6SLionel Sambucbool 38624684ddb6SLionel Sambucoperator< (const _CharT* __lhs, 38634684ddb6SLionel Sambuc const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT 38644684ddb6SLionel Sambuc{ 38654684ddb6SLionel Sambuc return __rhs.compare(__lhs) > 0; 38664684ddb6SLionel Sambuc} 38674684ddb6SLionel Sambuc 38684684ddb6SLionel Sambuc// operator> 38694684ddb6SLionel Sambuc 38704684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 38714684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 38724684ddb6SLionel Sambucbool 38734684ddb6SLionel Sambucoperator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs, 38744684ddb6SLionel Sambuc const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT 38754684ddb6SLionel Sambuc{ 38764684ddb6SLionel Sambuc return __rhs < __lhs; 38774684ddb6SLionel Sambuc} 38784684ddb6SLionel Sambuc 38794684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 38804684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 38814684ddb6SLionel Sambucbool 38824684ddb6SLionel Sambucoperator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs, 38834684ddb6SLionel Sambuc const _CharT* __rhs) _NOEXCEPT 38844684ddb6SLionel Sambuc{ 38854684ddb6SLionel Sambuc return __rhs < __lhs; 38864684ddb6SLionel Sambuc} 38874684ddb6SLionel Sambuc 38884684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 38894684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 38904684ddb6SLionel Sambucbool 38914684ddb6SLionel Sambucoperator> (const _CharT* __lhs, 38924684ddb6SLionel Sambuc const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT 38934684ddb6SLionel Sambuc{ 38944684ddb6SLionel Sambuc return __rhs < __lhs; 38954684ddb6SLionel Sambuc} 38964684ddb6SLionel Sambuc 38974684ddb6SLionel Sambuc// operator<= 38984684ddb6SLionel Sambuc 38994684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 39004684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 39014684ddb6SLionel Sambucbool 39024684ddb6SLionel Sambucoperator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, 39034684ddb6SLionel Sambuc const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT 39044684ddb6SLionel Sambuc{ 39054684ddb6SLionel Sambuc return !(__rhs < __lhs); 39064684ddb6SLionel Sambuc} 39074684ddb6SLionel Sambuc 39084684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 39094684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 39104684ddb6SLionel Sambucbool 39114684ddb6SLionel Sambucoperator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, 39124684ddb6SLionel Sambuc const _CharT* __rhs) _NOEXCEPT 39134684ddb6SLionel Sambuc{ 39144684ddb6SLionel Sambuc return !(__rhs < __lhs); 39154684ddb6SLionel Sambuc} 39164684ddb6SLionel Sambuc 39174684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 39184684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 39194684ddb6SLionel Sambucbool 39204684ddb6SLionel Sambucoperator<=(const _CharT* __lhs, 39214684ddb6SLionel Sambuc const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT 39224684ddb6SLionel Sambuc{ 39234684ddb6SLionel Sambuc return !(__rhs < __lhs); 39244684ddb6SLionel Sambuc} 39254684ddb6SLionel Sambuc 39264684ddb6SLionel Sambuc// operator>= 39274684ddb6SLionel Sambuc 39284684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 39294684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 39304684ddb6SLionel Sambucbool 39314684ddb6SLionel Sambucoperator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, 39324684ddb6SLionel Sambuc const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT 39334684ddb6SLionel Sambuc{ 39344684ddb6SLionel Sambuc return !(__lhs < __rhs); 39354684ddb6SLionel Sambuc} 39364684ddb6SLionel Sambuc 39374684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 39384684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 39394684ddb6SLionel Sambucbool 39404684ddb6SLionel Sambucoperator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, 39414684ddb6SLionel Sambuc const _CharT* __rhs) _NOEXCEPT 39424684ddb6SLionel Sambuc{ 39434684ddb6SLionel Sambuc return !(__lhs < __rhs); 39444684ddb6SLionel Sambuc} 39454684ddb6SLionel Sambuc 39464684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 39474684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 39484684ddb6SLionel Sambucbool 39494684ddb6SLionel Sambucoperator>=(const _CharT* __lhs, 39504684ddb6SLionel Sambuc const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT 39514684ddb6SLionel Sambuc{ 39524684ddb6SLionel Sambuc return !(__lhs < __rhs); 39534684ddb6SLionel Sambuc} 39544684ddb6SLionel Sambuc 39554684ddb6SLionel Sambuc// operator + 39564684ddb6SLionel Sambuc 39574684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 39584684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator> 39594684ddb6SLionel Sambucoperator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, 39604684ddb6SLionel Sambuc const basic_string<_CharT, _Traits, _Allocator>& __rhs) 39614684ddb6SLionel Sambuc{ 39624684ddb6SLionel Sambuc basic_string<_CharT, _Traits, _Allocator> __r(__lhs.get_allocator()); 39634684ddb6SLionel Sambuc typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = __lhs.size(); 39644684ddb6SLionel Sambuc typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = __rhs.size(); 39654684ddb6SLionel Sambuc __r.__init(__lhs.data(), __lhs_sz, __lhs_sz + __rhs_sz); 39664684ddb6SLionel Sambuc __r.append(__rhs.data(), __rhs_sz); 39674684ddb6SLionel Sambuc return __r; 39684684ddb6SLionel Sambuc} 39694684ddb6SLionel Sambuc 39704684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 39714684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator> 39724684ddb6SLionel Sambucoperator+(const _CharT* __lhs , const basic_string<_CharT,_Traits,_Allocator>& __rhs) 39734684ddb6SLionel Sambuc{ 39744684ddb6SLionel Sambuc basic_string<_CharT, _Traits, _Allocator> __r(__rhs.get_allocator()); 39754684ddb6SLionel Sambuc typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = _Traits::length(__lhs); 39764684ddb6SLionel Sambuc typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = __rhs.size(); 39774684ddb6SLionel Sambuc __r.__init(__lhs, __lhs_sz, __lhs_sz + __rhs_sz); 39784684ddb6SLionel Sambuc __r.append(__rhs.data(), __rhs_sz); 39794684ddb6SLionel Sambuc return __r; 39804684ddb6SLionel Sambuc} 39814684ddb6SLionel Sambuc 39824684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 39834684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator> 39844684ddb6SLionel Sambucoperator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Allocator>& __rhs) 39854684ddb6SLionel Sambuc{ 39864684ddb6SLionel Sambuc basic_string<_CharT, _Traits, _Allocator> __r(__rhs.get_allocator()); 39874684ddb6SLionel Sambuc typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = __rhs.size(); 39884684ddb6SLionel Sambuc __r.__init(&__lhs, 1, 1 + __rhs_sz); 39894684ddb6SLionel Sambuc __r.append(__rhs.data(), __rhs_sz); 39904684ddb6SLionel Sambuc return __r; 39914684ddb6SLionel Sambuc} 39924684ddb6SLionel Sambuc 39934684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 39944684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator> 39954684ddb6SLionel Sambucoperator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) 39964684ddb6SLionel Sambuc{ 39974684ddb6SLionel Sambuc basic_string<_CharT, _Traits, _Allocator> __r(__lhs.get_allocator()); 39984684ddb6SLionel Sambuc typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = __lhs.size(); 39994684ddb6SLionel Sambuc typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = _Traits::length(__rhs); 40004684ddb6SLionel Sambuc __r.__init(__lhs.data(), __lhs_sz, __lhs_sz + __rhs_sz); 40014684ddb6SLionel Sambuc __r.append(__rhs, __rhs_sz); 40024684ddb6SLionel Sambuc return __r; 40034684ddb6SLionel Sambuc} 40044684ddb6SLionel Sambuc 40054684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 40064684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator> 40074684ddb6SLionel Sambucoperator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, _CharT __rhs) 40084684ddb6SLionel Sambuc{ 40094684ddb6SLionel Sambuc basic_string<_CharT, _Traits, _Allocator> __r(__lhs.get_allocator()); 40104684ddb6SLionel Sambuc typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = __lhs.size(); 40114684ddb6SLionel Sambuc __r.__init(__lhs.data(), __lhs_sz, __lhs_sz + 1); 40124684ddb6SLionel Sambuc __r.push_back(__rhs); 40134684ddb6SLionel Sambuc return __r; 40144684ddb6SLionel Sambuc} 40154684ddb6SLionel Sambuc 40164684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 40174684ddb6SLionel Sambuc 40184684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 40194684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 40204684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator> 40214684ddb6SLionel Sambucoperator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) 40224684ddb6SLionel Sambuc{ 40234684ddb6SLionel Sambuc return _VSTD::move(__lhs.append(__rhs)); 40244684ddb6SLionel Sambuc} 40254684ddb6SLionel Sambuc 40264684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 40274684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 40284684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator> 40294684ddb6SLionel Sambucoperator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs) 40304684ddb6SLionel Sambuc{ 40314684ddb6SLionel Sambuc return _VSTD::move(__rhs.insert(0, __lhs)); 40324684ddb6SLionel Sambuc} 40334684ddb6SLionel Sambuc 40344684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 40354684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 40364684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator> 40374684ddb6SLionel Sambucoperator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs) 40384684ddb6SLionel Sambuc{ 40394684ddb6SLionel Sambuc return _VSTD::move(__lhs.append(__rhs)); 40404684ddb6SLionel Sambuc} 40414684ddb6SLionel Sambuc 40424684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 40434684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 40444684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator> 40454684ddb6SLionel Sambucoperator+(const _CharT* __lhs , basic_string<_CharT,_Traits,_Allocator>&& __rhs) 40464684ddb6SLionel Sambuc{ 40474684ddb6SLionel Sambuc return _VSTD::move(__rhs.insert(0, __lhs)); 40484684ddb6SLionel Sambuc} 40494684ddb6SLionel Sambuc 40504684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 40514684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 40524684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator> 40534684ddb6SLionel Sambucoperator+(_CharT __lhs, basic_string<_CharT,_Traits,_Allocator>&& __rhs) 40544684ddb6SLionel Sambuc{ 40554684ddb6SLionel Sambuc __rhs.insert(__rhs.begin(), __lhs); 40564684ddb6SLionel Sambuc return _VSTD::move(__rhs); 40574684ddb6SLionel Sambuc} 40584684ddb6SLionel Sambuc 40594684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 40604684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 40614684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator> 40624684ddb6SLionel Sambucoperator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const _CharT* __rhs) 40634684ddb6SLionel Sambuc{ 40644684ddb6SLionel Sambuc return _VSTD::move(__lhs.append(__rhs)); 40654684ddb6SLionel Sambuc} 40664684ddb6SLionel Sambuc 40674684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 40684684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 40694684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator> 40704684ddb6SLionel Sambucoperator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs) 40714684ddb6SLionel Sambuc{ 40724684ddb6SLionel Sambuc __lhs.push_back(__rhs); 40734684ddb6SLionel Sambuc return _VSTD::move(__lhs); 40744684ddb6SLionel Sambuc} 40754684ddb6SLionel Sambuc 40764684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 40774684ddb6SLionel Sambuc 40784684ddb6SLionel Sambuc// swap 40794684ddb6SLionel Sambuc 40804684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 40814684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 40824684ddb6SLionel Sambucvoid 40834684ddb6SLionel Sambucswap(basic_string<_CharT, _Traits, _Allocator>& __lhs, 40844684ddb6SLionel Sambuc basic_string<_CharT, _Traits, _Allocator>& __rhs) 40854684ddb6SLionel Sambuc _NOEXCEPT_(_NOEXCEPT_(__lhs.swap(__rhs))) 40864684ddb6SLionel Sambuc{ 40874684ddb6SLionel Sambuc __lhs.swap(__rhs); 40884684ddb6SLionel Sambuc} 40894684ddb6SLionel Sambuc 40904684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS 40914684ddb6SLionel Sambuc 40924684ddb6SLionel Sambuctypedef basic_string<char16_t> u16string; 40934684ddb6SLionel Sambuctypedef basic_string<char32_t> u32string; 40944684ddb6SLionel Sambuc 40954684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_UNICODE_CHARS 40964684ddb6SLionel Sambuc 40974684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS int stoi (const string& __str, size_t* __idx = 0, int __base = 10); 40984684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS long stol (const string& __str, size_t* __idx = 0, int __base = 10); 40994684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS unsigned long stoul (const string& __str, size_t* __idx = 0, int __base = 10); 41004684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS long long stoll (const string& __str, size_t* __idx = 0, int __base = 10); 41014684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS unsigned long long stoull(const string& __str, size_t* __idx = 0, int __base = 10); 41024684ddb6SLionel Sambuc 41034684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS float stof (const string& __str, size_t* __idx = 0); 41044684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS double stod (const string& __str, size_t* __idx = 0); 41054684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS long double stold(const string& __str, size_t* __idx = 0); 41064684ddb6SLionel Sambuc 41074684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS string to_string(int __val); 41084684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS string to_string(unsigned __val); 41094684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS string to_string(long __val); 41104684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS string to_string(unsigned long __val); 41114684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS string to_string(long long __val); 41124684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS string to_string(unsigned long long __val); 41134684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS string to_string(float __val); 41144684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS string to_string(double __val); 41154684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS string to_string(long double __val); 41164684ddb6SLionel Sambuc 41174684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS int stoi (const wstring& __str, size_t* __idx = 0, int __base = 10); 41184684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS long stol (const wstring& __str, size_t* __idx = 0, int __base = 10); 41194684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS unsigned long stoul (const wstring& __str, size_t* __idx = 0, int __base = 10); 41204684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS long long stoll (const wstring& __str, size_t* __idx = 0, int __base = 10); 41214684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS unsigned long long stoull(const wstring& __str, size_t* __idx = 0, int __base = 10); 41224684ddb6SLionel Sambuc 41234684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS float stof (const wstring& __str, size_t* __idx = 0); 41244684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS double stod (const wstring& __str, size_t* __idx = 0); 41254684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS long double stold(const wstring& __str, size_t* __idx = 0); 41264684ddb6SLionel Sambuc 41274684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS wstring to_wstring(int __val); 41284684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS wstring to_wstring(unsigned __val); 41294684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS wstring to_wstring(long __val); 41304684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS wstring to_wstring(unsigned long __val); 41314684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS wstring to_wstring(long long __val); 41324684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS wstring to_wstring(unsigned long long __val); 41334684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS wstring to_wstring(float __val); 41344684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS wstring to_wstring(double __val); 41354684ddb6SLionel Sambuc_LIBCPP_FUNC_VIS wstring to_wstring(long double __val); 41364684ddb6SLionel Sambuc 41374684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 41384684ddb6SLionel Sambuc const typename basic_string<_CharT, _Traits, _Allocator>::size_type 41394684ddb6SLionel Sambuc basic_string<_CharT, _Traits, _Allocator>::npos; 41404684ddb6SLionel Sambuc 41414684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 41424684ddb6SLionel Sambucstruct _LIBCPP_TYPE_VIS_ONLY hash<basic_string<_CharT, _Traits, _Allocator> > 41434684ddb6SLionel Sambuc : public unary_function<basic_string<_CharT, _Traits, _Allocator>, size_t> 41444684ddb6SLionel Sambuc{ 41454684ddb6SLionel Sambuc size_t 41464684ddb6SLionel Sambuc operator()(const basic_string<_CharT, _Traits, _Allocator>& __val) const _NOEXCEPT; 41474684ddb6SLionel Sambuc}; 41484684ddb6SLionel Sambuc 41494684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 41504684ddb6SLionel Sambucsize_t 41514684ddb6SLionel Sambuchash<basic_string<_CharT, _Traits, _Allocator> >::operator()( 41524684ddb6SLionel Sambuc const basic_string<_CharT, _Traits, _Allocator>& __val) const _NOEXCEPT 41534684ddb6SLionel Sambuc{ 41544684ddb6SLionel Sambuc return __do_string_hash(__val.data(), __val.data() + __val.size()); 41554684ddb6SLionel Sambuc} 41564684ddb6SLionel Sambuc 41574684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 41584684ddb6SLionel Sambucbasic_ostream<_CharT, _Traits>& 41594684ddb6SLionel Sambucoperator<<(basic_ostream<_CharT, _Traits>& __os, 41604684ddb6SLionel Sambuc const basic_string<_CharT, _Traits, _Allocator>& __str); 41614684ddb6SLionel Sambuc 41624684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 41634684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 41644684ddb6SLionel Sambucoperator>>(basic_istream<_CharT, _Traits>& __is, 41654684ddb6SLionel Sambuc basic_string<_CharT, _Traits, _Allocator>& __str); 41664684ddb6SLionel Sambuc 41674684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 41684684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 41694684ddb6SLionel Sambucgetline(basic_istream<_CharT, _Traits>& __is, 41704684ddb6SLionel Sambuc basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm); 41714684ddb6SLionel Sambuc 41724684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 41734684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 41744684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 41754684ddb6SLionel Sambucgetline(basic_istream<_CharT, _Traits>& __is, 41764684ddb6SLionel Sambuc basic_string<_CharT, _Traits, _Allocator>& __str); 41774684ddb6SLionel Sambuc 41784684ddb6SLionel Sambuc#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 41794684ddb6SLionel Sambuc 41804684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 41814684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 41824684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 41834684ddb6SLionel Sambucgetline(basic_istream<_CharT, _Traits>&& __is, 41844684ddb6SLionel Sambuc basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm); 41854684ddb6SLionel Sambuc 41864684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 41874684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY 41884684ddb6SLionel Sambucbasic_istream<_CharT, _Traits>& 41894684ddb6SLionel Sambucgetline(basic_istream<_CharT, _Traits>&& __is, 41904684ddb6SLionel Sambuc basic_string<_CharT, _Traits, _Allocator>& __str); 41914684ddb6SLionel Sambuc 41924684ddb6SLionel Sambuc#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 41934684ddb6SLionel Sambuc 41944684ddb6SLionel Sambuc#if _LIBCPP_DEBUG_LEVEL >= 2 41954684ddb6SLionel Sambuc 41964684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 41974684ddb6SLionel Sambucbool 41984684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::__dereferenceable(const const_iterator* __i) const 41994684ddb6SLionel Sambuc{ 42004684ddb6SLionel Sambuc return this->data() <= _VSTD::__to_raw_pointer(__i->base()) && 42014684ddb6SLionel Sambuc _VSTD::__to_raw_pointer(__i->base()) < this->data() + this->size(); 42024684ddb6SLionel Sambuc} 42034684ddb6SLionel Sambuc 42044684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 42054684ddb6SLionel Sambucbool 42064684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::__decrementable(const const_iterator* __i) const 42074684ddb6SLionel Sambuc{ 42084684ddb6SLionel Sambuc return this->data() < _VSTD::__to_raw_pointer(__i->base()) && 42094684ddb6SLionel Sambuc _VSTD::__to_raw_pointer(__i->base()) <= this->data() + this->size(); 42104684ddb6SLionel Sambuc} 42114684ddb6SLionel Sambuc 42124684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 42134684ddb6SLionel Sambucbool 42144684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::__addable(const const_iterator* __i, ptrdiff_t __n) const 42154684ddb6SLionel Sambuc{ 42164684ddb6SLionel Sambuc const value_type* __p = _VSTD::__to_raw_pointer(__i->base()) + __n; 42174684ddb6SLionel Sambuc return this->data() <= __p && __p <= this->data() + this->size(); 42184684ddb6SLionel Sambuc} 42194684ddb6SLionel Sambuc 42204684ddb6SLionel Sambuctemplate<class _CharT, class _Traits, class _Allocator> 42214684ddb6SLionel Sambucbool 42224684ddb6SLionel Sambucbasic_string<_CharT, _Traits, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __n) const 42234684ddb6SLionel Sambuc{ 42244684ddb6SLionel Sambuc const value_type* __p = _VSTD::__to_raw_pointer(__i->base()) + __n; 42254684ddb6SLionel Sambuc return this->data() <= __p && __p < this->data() + this->size(); 42264684ddb6SLionel Sambuc} 42274684ddb6SLionel Sambuc 42284684ddb6SLionel Sambuc#endif // _LIBCPP_DEBUG_LEVEL >= 2 42294684ddb6SLionel Sambuc 42304684ddb6SLionel Sambuc#if _LIBCPP_STD_VER > 11 42314684ddb6SLionel Sambuc// Literal suffixes for basic_string [basic.string.literals] 42324684ddb6SLionel Sambucinline namespace literals 42334684ddb6SLionel Sambuc{ 42344684ddb6SLionel Sambuc inline namespace string_literals 42354684ddb6SLionel Sambuc { 42364684ddb6SLionel Sambuc inline _LIBCPP_INLINE_VISIBILITY 42374684ddb6SLionel Sambuc basic_string<char> operator "" s( const char *__str, size_t __len ) 42384684ddb6SLionel Sambuc { 42394684ddb6SLionel Sambuc return basic_string<char> (__str, __len); 42404684ddb6SLionel Sambuc } 42414684ddb6SLionel Sambuc 42424684ddb6SLionel Sambuc inline _LIBCPP_INLINE_VISIBILITY 42434684ddb6SLionel Sambuc basic_string<wchar_t> operator "" s( const wchar_t *__str, size_t __len ) 42444684ddb6SLionel Sambuc { 42454684ddb6SLionel Sambuc return basic_string<wchar_t> (__str, __len); 42464684ddb6SLionel Sambuc } 42474684ddb6SLionel Sambuc 42484684ddb6SLionel Sambuc inline _LIBCPP_INLINE_VISIBILITY 42494684ddb6SLionel Sambuc basic_string<char16_t> operator "" s( const char16_t *__str, size_t __len ) 42504684ddb6SLionel Sambuc { 42514684ddb6SLionel Sambuc return basic_string<char16_t> (__str, __len); 42524684ddb6SLionel Sambuc } 42534684ddb6SLionel Sambuc 42544684ddb6SLionel Sambuc inline _LIBCPP_INLINE_VISIBILITY 42554684ddb6SLionel Sambuc basic_string<char32_t> operator "" s( const char32_t *__str, size_t __len ) 42564684ddb6SLionel Sambuc { 42574684ddb6SLionel Sambuc return basic_string<char32_t> (__str, __len); 42584684ddb6SLionel Sambuc } 42594684ddb6SLionel Sambuc } 42604684ddb6SLionel Sambuc} 42614684ddb6SLionel Sambuc#endif 42624684ddb6SLionel Sambuc 42634684ddb6SLionel Sambuc_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_string<char>) 42644684ddb6SLionel Sambuc_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_string<wchar_t>) 42654684ddb6SLionel Sambuc_LIBCPP_EXTERN_TEMPLATE(string operator+<char, char_traits<char>, allocator<char> >(char const*, string const&)) 42664684ddb6SLionel Sambuc 42674684ddb6SLionel Sambuc_LIBCPP_END_NAMESPACE_STD 42684684ddb6SLionel Sambuc 42694684ddb6SLionel Sambuc#endif // _LIBCPP_STRING 4270