diff options
Diffstat (limited to 'tests/libcxx/include/string')
-rw-r--r-- | tests/libcxx/include/string | 3781 |
1 files changed, 0 insertions, 3781 deletions
diff --git a/tests/libcxx/include/string b/tests/libcxx/include/string deleted file mode 100644 index 469e3dd5..00000000 --- a/tests/libcxx/include/string +++ /dev/null @@ -1,3781 +0,0 @@ -// -*- C++ -*- -//===--------------------------- string -----------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP_STRING -#define _LIBCPP_STRING - -/* - string synopsis - -namespace std -{ - -template <class stateT> -class fpos -{ -private: - stateT st; -public: - fpos(streamoff = streamoff()); - - operator streamoff() const; - - stateT state() const; - void state(stateT); - - fpos& operator+=(streamoff); - fpos operator+ (streamoff) const; - fpos& operator-=(streamoff); - fpos operator- (streamoff) const; -}; - -template <class stateT> streamoff operator-(const fpos<stateT>& x, const fpos<stateT>& y); - -template <class stateT> bool operator==(const fpos<stateT>& x, const fpos<stateT>& y); -template <class stateT> bool operator!=(const fpos<stateT>& x, const fpos<stateT>& y); - -template <class charT> -struct char_traits -{ - typedef charT char_type; - typedef ... int_type; - typedef streamoff off_type; - typedef streampos pos_type; - typedef mbstate_t state_type; - - static void assign(char_type& c1, const char_type& c2); - static bool eq(char_type c1, char_type c2); - static bool lt(char_type c1, char_type c2); - - static int compare(const char_type* s1, const char_type* s2, size_t n); - static size_t length(const char_type* s); - static const char_type* find(const char_type* s, size_t n, const char_type& a); - static char_type* move(char_type* s1, const char_type* s2, size_t n); - static char_type* copy(char_type* s1, const char_type* s2, size_t n); - static char_type* assign(char_type* s, size_t n, char_type a); - - static int_type not_eof(int_type c); - static char_type to_char_type(int_type c); - static int_type to_int_type(char_type c); - static bool eq_int_type(int_type c1, int_type c2); - static int_type eof(); -}; - -template <> struct char_traits<char>; -template <> struct char_traits<wchar_t>; - -template<class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > -class basic_string -{ -public: -// types: - typedef traits traits_type; - typedef typename traits_type::char_type value_type; - typedef Allocator allocator_type; - typedef typename allocator_type::size_type size_type; - typedef typename allocator_type::difference_type difference_type; - typedef typename allocator_type::reference reference; - typedef typename allocator_type::const_reference const_reference; - typedef typename allocator_type::pointer pointer; - typedef typename allocator_type::const_pointer const_pointer; - typedef implementation-defined iterator; - typedef implementation-defined const_iterator; - typedef std::reverse_iterator<iterator> reverse_iterator; - typedef std::reverse_iterator<const_iterator> const_reverse_iterator; - - static const size_type npos = -1; - - explicit basic_string(const allocator_type& a = allocator_type()); - basic_string(const basic_string& str); - basic_string(basic_string&& str); - basic_string(const basic_string& str, size_type pos, size_type n = npos, - const allocator_type& a = allocator_type()); - basic_string(const_pointer s, const allocator_type& a = allocator_type()); - basic_string(const_pointer s, size_type n, const allocator_type& a = allocator_type()); - basic_string(size_type n, value_type c, const allocator_type& a = allocator_type()); - template<class InputIterator> - basic_string(InputIterator begin, InputIterator end, - const allocator_type& a = allocator_type()); - basic_string(initializer_list<value_type>, const Allocator& = Allocator()); - basic_string(const basic_string&, const Allocator&); - basic_string(basic_string&&, const Allocator&); - - ~basic_string(); - - basic_string& operator=(const basic_string& str); - basic_string& operator=(const_pointer s); - basic_string& operator=(value_type c); - basic_string& operator=(initializer_list<value_type>); - - iterator begin(); - const_iterator begin() const; - iterator end(); - const_iterator end() const; - - reverse_iterator rbegin(); - const_reverse_iterator rbegin() const; - reverse_iterator rend(); - const_reverse_iterator rend() const; - - const_iterator cbegin() const; - const_iterator cend() const; - const_reverse_iterator crbegin() const; - const_reverse_iterator crend() const; - - size_type size() const; - size_type length() const; - size_type max_size() const; - size_type capacity() const; - - void resize(size_type n, value_type c); - void resize(size_type n); - - void reserve(size_type res_arg = 0); - void shrink_to_fit(); - void clear(); - bool empty() const; - - const_reference operator[](size_type pos) const; - reference operator[](size_type pos); - - const_reference at(size_type n) const; - reference at(size_type n); - - basic_string& operator+=(const basic_string& str); - basic_string& operator+=(const_pointer s); - basic_string& operator+=(value_type c); - basic_string& operator+=(initializer_list<value_type>); - - basic_string& append(const basic_string& str); - basic_string& append(const basic_string& str, size_type pos, size_type n); - basic_string& append(const_pointer s, size_type n); - basic_string& append(const_pointer s); - basic_string& append(size_type n, value_type c); - template<class InputIterator> - basic_string& append(InputIterator first, InputIterator last); - basic_string& append(initializer_list<value_type>); - - void push_back(value_type c); - void pop_back(); - reference front(); - const_reference front() const; - reference back(); - const_reference back() const; - - basic_string& assign(const basic_string& str); - basic_string& assign(const basic_string& str, size_type pos, size_type n); - basic_string& assign(const_pointer s, size_type n); - basic_string& assign(const_pointer s); - basic_string& assign(size_type n, value_type c); - template<class InputIterator> - basic_string& assign(InputIterator first, InputIterator last); - basic_string& assign(initializer_list<value_type>); - - basic_string& insert(size_type pos1, const basic_string& str); - basic_string& insert(size_type pos1, const basic_string& str, - size_type pos2, size_type n); - basic_string& insert(size_type pos, const_pointer s, size_type n); - basic_string& insert(size_type pos, const_pointer s); - basic_string& insert(size_type pos, size_type n, value_type c); - iterator insert(const_iterator p, value_type c); - iterator insert(const_iterator p, size_type n, value_type c); - template<class InputIterator> - iterator insert(const_iterator p, InputIterator first, InputIterator last); - iterator insert(const_iterator p, initializer_list<value_type>); - - basic_string& erase(size_type pos = 0, size_type n = npos); - iterator erase(const_iterator position); - iterator erase(const_iterator first, const_iterator last); - - basic_string& replace(size_type pos1, size_type n1, const basic_string& str); - basic_string& replace(size_type pos1, size_type n1, const basic_string& str, - size_type pos2, size_type n2); - basic_string& replace(size_type pos, size_type n1, const_pointer s, size_type n2); - basic_string& replace(size_type pos, size_type n1, const_pointer s); - basic_string& replace(size_type pos, size_type n1, size_type n2, value_type c); - basic_string& replace(const_iterator i1, const_iterator i2, const basic_string& str); - basic_string& replace(const_iterator i1, const_iterator i2, const_pointer s, size_type n); - basic_string& replace(const_iterator i1, const_iterator i2, const_pointer s); - basic_string& replace(const_iterator i1, const_iterator i2, size_type n, value_type c); - template<class InputIterator> - basic_string& replace(const_iterator i1, const_iterator i2, InputIterator j1, InputIterator j2); - basic_string& replace(const_iterator i1, const_iterator i2, initializer_list<value_type>); - - size_type copy(pointer s, size_type n, size_type pos = 0) const; - basic_string substr(size_type pos = 0, size_type n = npos) const; - - void swap(basic_string& str); - - const_pointer c_str() const; - const_pointer data() const; - - allocator_type get_allocator() const; - - size_type find(const basic_string& str, size_type pos = 0) const; - size_type find(const_pointer s, size_type pos, size_type n) const; - size_type find(const_pointer s, size_type pos = 0) const; - size_type find(value_type c, size_type pos = 0) const; - - size_type rfind(const basic_string& str, size_type pos = npos) const; - size_type rfind(const_pointer s, size_type pos, size_type n) const; - size_type rfind(const_pointer s, size_type pos = npos) const; - size_type rfind(value_type c, size_type pos = npos) const; - - size_type find_first_of(const basic_string& str, size_type pos = 0) const; - size_type find_first_of(const_pointer s, size_type pos, size_type n) const; - size_type find_first_of(const_pointer s, size_type pos = 0) const; - size_type find_first_of(value_type c, size_type pos = 0) const; - - size_type find_last_of(const basic_string& str, size_type pos = npos) const; - size_type find_last_of(const_pointer s, size_type pos, size_type n) const; - size_type find_last_of(const_pointer s, size_type pos = npos) const; - size_type find_last_of(value_type c, size_type pos = npos) const; - - size_type find_first_not_of(const basic_string& str, size_type pos = 0) const; - size_type find_first_not_of(const_pointer s, size_type pos, size_type n) const; - size_type find_first_not_of(const_pointer s, size_type pos = 0) const; - size_type find_first_not_of(value_type c, size_type pos = 0) const; - - size_type find_last_not_of(const basic_string& str, size_type pos = npos) const; - size_type find_last_not_of(const_pointer s, size_type pos, size_type n) const; - size_type find_last_not_of(const_pointer s, size_type pos = npos) const; - size_type find_last_not_of(value_type c, size_type pos = npos) const; - - int compare(const basic_string& str) const; - int compare(size_type pos1, size_type n1, const basic_string& str) const; - int compare(size_type pos1, size_type n1, const basic_string& str, - size_type pos2, size_type n2) const; - int compare(const_pointer s) const; - int compare(size_type pos1, size_type n1, const_pointer s) const; - int compare(size_type pos1, size_type n1, const_pointer s, size_type n2) const; - - bool __invariants() const; -}; - -template<class charT, class traits, class Allocator> -basic_string<charT, traits, Allocator> -operator+(const basic_string<charT, traits, Allocator>& lhs, - const basic_string<charT, traits, Allocator>& rhs); - -template<class charT, class traits, class Allocator> -basic_string<charT, traits, Allocator> -operator+(const charT* lhs , const basic_string<charT,traits,Allocator>&rhs); - -template<class charT, class traits, class Allocator> -basic_string<charT, traits, Allocator> -operator+(charT lhs, const basic_string<charT,traits,Allocator>& rhs); - -template<class charT, class traits, class Allocator> -basic_string<charT, traits, Allocator> -operator+(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs); - -template<class charT, class traits, class Allocator> -basic_string<charT, traits, Allocator> -operator+(const basic_string<charT, traits, Allocator>& lhs, charT rhs); - -template<class charT, class traits, class Allocator> -bool operator==(const basic_string<charT, traits, Allocator>& lhs, - const basic_string<charT, traits, Allocator>& rhs); - -template<class charT, class traits, class Allocator> -bool operator==(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs); - -template<class charT, class traits, class Allocator> -bool operator==(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs); - -template<class charT, class traits, class Allocator> -bool operator!=(const basic_string<charT,traits,Allocator>& lhs, - const basic_string<charT, traits, Allocator>& rhs); - -template<class charT, class traits, class Allocator> -bool operator!=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs); - -template<class charT, class traits, class Allocator> -bool operator!=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs); - -template<class charT, class traits, class Allocator> -bool operator< (const basic_string<charT, traits, Allocator>& lhs, - const basic_string<charT, traits, Allocator>& rhs); - -template<class charT, class traits, class Allocator> -bool operator< (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs); - -template<class charT, class traits, class Allocator> -bool operator< (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs); - -template<class charT, class traits, class Allocator> -bool operator> (const basic_string<charT, traits, Allocator>& lhs, - const basic_string<charT, traits, Allocator>& rhs); - -template<class charT, class traits, class Allocator> -bool operator> (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs); - -template<class charT, class traits, class Allocator> -bool operator> (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs); - -template<class charT, class traits, class Allocator> -bool operator<=(const basic_string<charT, traits, Allocator>& lhs, - const basic_string<charT, traits, Allocator>& rhs); - -template<class charT, class traits, class Allocator> -bool operator<=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs); - -template<class charT, class traits, class Allocator> -bool operator<=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs); - -template<class charT, class traits, class Allocator> -bool operator>=(const basic_string<charT, traits, Allocator>& lhs, - const basic_string<charT, traits, Allocator>& rhs); - -template<class charT, class traits, class Allocator> -bool operator>=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs); - -template<class charT, class traits, class Allocator> -bool operator>=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs); - -template<class charT, class traits, class Allocator> -void swap(basic_string<charT, traits, Allocator>& lhs, - basic_string<charT, traits, Allocator>& rhs); - -template<class charT, class traits, class Allocator> -basic_istream<charT, traits>& -operator>>(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str); - -template<class charT, class traits, class Allocator> -basic_ostream<charT, traits>& -operator<<(basic_ostream<charT, traits>& os, const basic_string<charT, traits, Allocator>& str); - -template<class charT, class traits, class Allocator> -basic_istream<charT, traits>& -getline(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str, - charT delim); - -template<class charT, class traits, class Allocator> -basic_istream<charT, traits>& -getline(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str); - -typedef basic_string<char> string; -typedef basic_string<wchar_t> wstring; -typedef basic_string<char16_t> u16string; -typedef basic_string<char32_t> u32string; - -int stoi (const string& str, size_t* idx = 0, int base = 10); -long stol (const string& str, size_t* idx = 0, int base = 10); -unsigned long stoul (const string& str, size_t* idx = 0, int base = 10); -long long stoll (const string& str, size_t* idx = 0, int base = 10); -unsigned long long stoull(const string& str, size_t* idx = 0, int base = 10); - -float stof (const string& str, size_t* idx = 0); -double stod (const string& str, size_t* idx = 0); -long double stold(const string& str, size_t* idx = 0); - -string to_string(int val); -string to_string(unsigned val); -string to_string(long val); -string to_string(unsigned long val); -string to_string(long long val); -string to_string(unsigned long long val); -string to_string(float val); -string to_string(double val); -string to_string(long double val); - -int stoi (const wstring& str, size_t* idx = 0, int base = 10); -long stol (const wstring& str, size_t* idx = 0, int base = 10); -unsigned long stoul (const wstring& str, size_t* idx = 0, int base = 10); -long long stoll (const wstring& str, size_t* idx = 0, int base = 10); -unsigned long long stoull(const wstring& str, size_t* idx = 0, int base = 10); - -float stof (const wstring& str, size_t* idx = 0); -double stod (const wstring& str, size_t* idx = 0); -long double stold(const wstring& str, size_t* idx = 0); - -wstring to_wstring(int val); -wstring to_wstring(unsigned val); -wstring to_wstring(long val); -wstring to_wstring(unsigned long val); -wstring to_wstring(long long val); -wstring to_wstring(unsigned long long val); -wstring to_wstring(float val); -wstring to_wstring(double val); -wstring to_wstring(long double val); - -template <> struct hash<string>; -template <> struct hash<u16string>; -template <> struct hash<u32string>; -template <> struct hash<wstring>; - -} // std - -*/ - -#include <__config> -#include <iosfwd> -#include <cstring> -#include <cstdio> // For EOF. -#include <cwchar> -#include <algorithm> -#include <iterator> -#include <utility> -#include <memory> -#include <stdexcept> -#include <type_traits> -#include <initializer_list> -#include <__functional_base> -#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS -#include <cstdint> -#endif -#if defined(_LIBCPP_NO_EXCEPTIONS) || defined(_LIBCPP_DEBUG) -#include <cassert> -#endif - -#pragma GCC system_header - -_LIBCPP_BEGIN_NAMESPACE_STD - -// fpos - -template <class _StateT> -class _LIBCPP_VISIBLE fpos -{ -private: - _StateT __st_; - streamoff __off_; -public: - _LIBCPP_INLINE_VISIBILITY fpos(streamoff __off = streamoff()) : __st_(), __off_(__off) {} - - _LIBCPP_INLINE_VISIBILITY operator streamoff() const {return __off_;} - - _LIBCPP_INLINE_VISIBILITY _StateT state() const {return __st_;} - _LIBCPP_INLINE_VISIBILITY void state(_StateT __st) {__st_ = __st;} - - _LIBCPP_INLINE_VISIBILITY fpos& operator+=(streamoff __off) {__off_ += __off; return *this;} - _LIBCPP_INLINE_VISIBILITY fpos operator+ (streamoff __off) const {fpos __t(*this); __t += __off; return __t;} - _LIBCPP_INLINE_VISIBILITY fpos& operator-=(streamoff __off) {__off_ -= __off; return *this;} - _LIBCPP_INLINE_VISIBILITY fpos operator- (streamoff __off) const {fpos __t(*this); __t -= __off; return __t;} -}; - -template <class _StateT> -inline _LIBCPP_INLINE_VISIBILITY -streamoff operator-(const fpos<_StateT>& __x, const fpos<_StateT>& __y) - {return streamoff(__x) - streamoff(__y);} - -template <class _StateT> -inline _LIBCPP_INLINE_VISIBILITY -bool operator==(const fpos<_StateT>& __x, const fpos<_StateT>& __y) - {return streamoff(__x) == streamoff(__y);} - -template <class _StateT> -inline _LIBCPP_INLINE_VISIBILITY -bool operator!=(const fpos<_StateT>& __x, const fpos<_StateT>& __y) - {return streamoff(__x) != streamoff(__y);} - -// char_traits - -template <class _CharT> -struct _LIBCPP_VISIBLE char_traits -{ - typedef _CharT char_type; - typedef int int_type; - typedef streamoff off_type; - typedef streampos pos_type; - typedef mbstate_t state_type; - - _LIBCPP_INLINE_VISIBILITY static void assign(char_type& __c1, const char_type& __c2) {__c1 = __c2;} - _LIBCPP_INLINE_VISIBILITY static bool eq(char_type __c1, char_type __c2) {return __c1 == __c2;} - _LIBCPP_INLINE_VISIBILITY static bool lt(char_type __c1, char_type __c2) {return __c1 < __c2;} - - static int compare(const char_type* __s1, const char_type* __s2, size_t __n); - static size_t length(const char_type* __s); - static const char_type* find(const char_type* __s, size_t __n, const char_type& __a); - static char_type* move(char_type* __s1, const char_type* __s2, size_t __n); - static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n); - static char_type* assign(char_type* __s, size_t __n, char_type __a); - - _LIBCPP_INLINE_VISIBILITY static int_type not_eof(int_type __c) - {return eq_int_type(__c, eof()) ? ~eof() : __c;} - _LIBCPP_INLINE_VISIBILITY static char_type to_char_type(int_type __c) {return char_type(__c);} - _LIBCPP_INLINE_VISIBILITY static int_type to_int_type(char_type __c) {return int_type(__c);} - _LIBCPP_INLINE_VISIBILITY static bool eq_int_type(int_type __c1, int_type __c2) - {return __c1 == __c2;} - _LIBCPP_INLINE_VISIBILITY static int_type eof() {return int_type(EOF);} -}; - -template <class _CharT> -int -char_traits<_CharT>::compare(const char_type* __s1, const char_type* __s2, size_t __n) -{ - for (; __n; --__n, ++__s1, ++__s2) - { - if (lt(*__s1, *__s2)) - return -1; - if (lt(*__s2, *__s1)) - return 1; - } - return 0; -} - -template <class _CharT> -inline _LIBCPP_INLINE_VISIBILITY -size_t -char_traits<_CharT>::length(const char_type* __s) -{ - size_t __len = 0; - for (; !eq(*__s, char_type(0)); ++__s) - ++__len; - return __len; -} - -template <class _CharT> -inline _LIBCPP_INLINE_VISIBILITY -const _CharT* -char_traits<_CharT>::find(const char_type* __s, size_t __n, const char_type& __a) -{ - for (; __n; --__n) - { - if (eq(*__s, __a)) - return __s; - ++__s; - } - return 0; -} - -template <class _CharT> -_CharT* -char_traits<_CharT>::move(char_type* __s1, const char_type* __s2, size_t __n) -{ - char_type* __r = __s1; - if (__s1 < __s2) - { - for (; __n; --__n, ++__s1, ++__s2) - assign(*__s1, *__s2); - } - else if (__s2 < __s1) - { - __s1 += __n; - __s2 += __n; - for (; __n; --__n) - assign(*--__s1, *--__s2); - } - return __r; -} - -template <class _CharT> -inline _LIBCPP_INLINE_VISIBILITY -_CharT* -char_traits<_CharT>::copy(char_type* __s1, const char_type* __s2, size_t __n) -{ - char_type* __r = __s1; - for (; __n; --__n, ++__s1, ++__s2) - assign(*__s1, *__s2); - return __r; -} - -template <class _CharT> -inline _LIBCPP_INLINE_VISIBILITY -_CharT* -char_traits<_CharT>::assign(char_type* __s, size_t __n, char_type __a) -{ - char_type* __r = __s; - for (; __n; --__n, ++__s) - assign(*__s, __a); - return __r; -} - -// char_traits<char> - -template <> -struct _LIBCPP_VISIBLE char_traits<char> -{ - typedef char char_type; - typedef int int_type; - typedef streamoff off_type; - typedef streampos pos_type; - typedef mbstate_t state_type; - - _LIBCPP_INLINE_VISIBILITY static void assign(char_type& __c1, const char_type& __c2) {__c1 = __c2;} - _LIBCPP_INLINE_VISIBILITY static bool eq(char_type __c1, char_type __c2) {return __c1 == __c2;} - _LIBCPP_INLINE_VISIBILITY static bool lt(char_type __c1, char_type __c2) - {return (unsigned char)__c1 < (unsigned char)__c2;} - - _LIBCPP_INLINE_VISIBILITY static int compare(const char_type* __s1, const char_type* __s2, size_t __n) - {return memcmp(__s1, __s2, __n);} - _LIBCPP_INLINE_VISIBILITY static size_t length(const char_type* __s) {return strlen(__s);} - _LIBCPP_INLINE_VISIBILITY static const char_type* find(const char_type* __s, size_t __n, const char_type& __a) - {return (const char_type*)memchr(__s, to_int_type(__a), __n);} - _LIBCPP_INLINE_VISIBILITY static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) - {return (char_type*)memmove(__s1, __s2, __n);} - _LIBCPP_INLINE_VISIBILITY static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) - {return (char_type*)memcpy(__s1, __s2, __n);} - _LIBCPP_INLINE_VISIBILITY static char_type* assign(char_type* __s, size_t __n, char_type __a) - {return (char_type*)memset(__s, to_int_type(__a), __n);} - - _LIBCPP_INLINE_VISIBILITY static int_type not_eof(int_type __c) - {return eq_int_type(__c, eof()) ? ~eof() : __c;} - _LIBCPP_INLINE_VISIBILITY static char_type to_char_type(int_type __c) {return char_type(__c);} - _LIBCPP_INLINE_VISIBILITY static int_type to_int_type(char_type __c) {return int_type((unsigned char)__c);} - _LIBCPP_INLINE_VISIBILITY static bool eq_int_type(int_type __c1, int_type __c2) - {return __c1 == __c2;} - _LIBCPP_INLINE_VISIBILITY static int_type eof() {return int_type(EOF);} -}; - -// char_traits<wchar_t> - -template <> -struct _LIBCPP_VISIBLE char_traits<wchar_t> -{ - typedef wchar_t char_type; - typedef wint_t int_type; - typedef streamoff off_type; - typedef streampos pos_type; - typedef mbstate_t state_type; - - _LIBCPP_INLINE_VISIBILITY static void assign(char_type& __c1, const char_type& __c2) {__c1 = __c2;} - _LIBCPP_INLINE_VISIBILITY static bool eq(char_type __c1, char_type __c2) {return __c1 == __c2;} - _LIBCPP_INLINE_VISIBILITY static bool lt(char_type __c1, char_type __c2) - {return __c1 < __c2;} - - _LIBCPP_INLINE_VISIBILITY static int compare(const char_type* __s1, const char_type* __s2, size_t __n) - {return wmemcmp(__s1, __s2, __n);} - _LIBCPP_INLINE_VISIBILITY static size_t length(const char_type* __s) {return wcslen(__s);} - _LIBCPP_INLINE_VISIBILITY static const char_type* find(const char_type* __s, size_t __n, const char_type& __a) - {return (const char_type*)wmemchr(__s, __a, __n);} - _LIBCPP_INLINE_VISIBILITY static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) - {return (char_type*)wmemmove(__s1, __s2, __n);} - _LIBCPP_INLINE_VISIBILITY static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) - {return (char_type*)wmemcpy(__s1, __s2, __n);} - _LIBCPP_INLINE_VISIBILITY static char_type* assign(char_type* __s, size_t __n, char_type __a) - {return (char_type*)wmemset(__s, __a, __n);} - - _LIBCPP_INLINE_VISIBILITY static int_type not_eof(int_type __c) - {return eq_int_type(__c, eof()) ? ~eof() : __c;} - _LIBCPP_INLINE_VISIBILITY static char_type to_char_type(int_type __c) {return char_type(__c);} - _LIBCPP_INLINE_VISIBILITY static int_type to_int_type(char_type __c) {return int_type(__c);} - _LIBCPP_INLINE_VISIBILITY static bool eq_int_type(int_type __c1, int_type __c2) - {return __c1 == __c2;} - _LIBCPP_INLINE_VISIBILITY static int_type eof() {return int_type(WEOF);} -}; - -#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS - -template <> -struct _LIBCPP_VISIBLE char_traits<char16_t> -{ - typedef char16_t char_type; - typedef uint_least16_t int_type; - typedef streamoff off_type; - typedef u16streampos pos_type; - typedef mbstate_t state_type; - - _LIBCPP_INLINE_VISIBILITY static void assign(char_type& __c1, const char_type& __c2) {__c1 = __c2;} - _LIBCPP_INLINE_VISIBILITY static bool eq(char_type __c1, char_type __c2) {return __c1 == __c2;} - _LIBCPP_INLINE_VISIBILITY static bool lt(char_type __c1, char_type __c2) {return __c1 < __c2;} - - static int compare(const char_type* __s1, const char_type* __s2, size_t __n); - static size_t length(const char_type* __s); - static const char_type* find(const char_type* __s, size_t __n, const char_type& __a); - static char_type* move(char_type* __s1, const char_type* __s2, size_t __n); - static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n); - static char_type* assign(char_type* __s, size_t __n, char_type __a); - - _LIBCPP_INLINE_VISIBILITY static int_type not_eof(int_type __c) - {return eq_int_type(__c, eof()) ? ~eof() : __c;} - _LIBCPP_INLINE_VISIBILITY static char_type to_char_type(int_type __c) {return char_type(__c);} - _LIBCPP_INLINE_VISIBILITY static int_type to_int_type(char_type __c) {return int_type(__c);} - _LIBCPP_INLINE_VISIBILITY static bool eq_int_type(int_type __c1, int_type __c2) - {return __c1 == __c2;} - _LIBCPP_INLINE_VISIBILITY static int_type eof() {return int_type(0xDFFF);} -}; - -inline _LIBCPP_INLINE_VISIBILITY -int -char_traits<char16_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) -{ - for (; __n; --__n, ++__s1, ++__s2) - { - if (lt(*__s1, *__s2)) - return -1; - if (lt(*__s2, *__s1)) - return 1; - } - return 0; -} - -inline _LIBCPP_INLINE_VISIBILITY -size_t -char_traits<char16_t>::length(const char_type* __s) -{ - size_t __len = 0; - for (; !eq(*__s, char_type(0)); ++__s) - ++__len; - return __len; -} - -inline _LIBCPP_INLINE_VISIBILITY -const char16_t* -char_traits<char16_t>::find(const char_type* __s, size_t __n, const char_type& __a) -{ - for (; __n; --__n) - { - if (eq(*__s, __a)) - return __s; - ++__s; - } - return 0; -} - -inline _LIBCPP_INLINE_VISIBILITY -char16_t* -char_traits<char16_t>::move(char_type* __s1, const char_type* __s2, size_t __n) -{ - char_type* __r = __s1; - if (__s1 < __s2) - { - for (; __n; --__n, ++__s1, ++__s2) - assign(*__s1, *__s2); - } - else if (__s2 < __s1) - { - __s1 += __n; - __s2 += __n; - for (; __n; --__n) - assign(*--__s1, *--__s2); - } - return __r; -} - -inline _LIBCPP_INLINE_VISIBILITY -char16_t* -char_traits<char16_t>::copy(char_type* __s1, const char_type* __s2, size_t __n) -{ - char_type* __r = __s1; - for (; __n; --__n, ++__s1, ++__s2) - assign(*__s1, *__s2); - return __r; -} - -inline _LIBCPP_INLINE_VISIBILITY -char16_t* -char_traits<char16_t>::assign(char_type* __s, size_t __n, char_type __a) -{ - char_type* __r = __s; - for (; __n; --__n, ++__s) - assign(*__s, __a); - return __r; -} - -template <> -struct _LIBCPP_VISIBLE char_traits<char32_t> -{ - typedef char32_t char_type; - typedef uint_least32_t int_type; - typedef streamoff off_type; - typedef u32streampos pos_type; - typedef mbstate_t state_type; - - _LIBCPP_INLINE_VISIBILITY static void assign(char_type& __c1, const char_type& __c2) {__c1 = __c2;} - _LIBCPP_INLINE_VISIBILITY static bool eq(char_type __c1, char_type __c2) {return __c1 == __c2;} - _LIBCPP_INLINE_VISIBILITY static bool lt(char_type __c1, char_type __c2) {return __c1 < __c2;} - - static int compare(const char_type* __s1, const char_type* __s2, size_t __n); - static size_t length(const char_type* __s); - static const char_type* find(const char_type* __s, size_t __n, const char_type& __a); - static char_type* move(char_type* __s1, const char_type* __s2, size_t __n); - static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n); - static char_type* assign(char_type* __s, size_t __n, char_type __a); - - _LIBCPP_INLINE_VISIBILITY static int_type not_eof(int_type __c) - {return eq_int_type(__c, eof()) ? ~eof() : __c;} - _LIBCPP_INLINE_VISIBILITY static char_type to_char_type(int_type __c) {return char_type(__c);} - _LIBCPP_INLINE_VISIBILITY static int_type to_int_type(char_type __c) {return int_type(__c);} - _LIBCPP_INLINE_VISIBILITY static bool eq_int_type(int_type __c1, int_type __c2) - {return __c1 == __c2;} - _LIBCPP_INLINE_VISIBILITY static int_type eof() {return int_type(0xFFFFFFFF);} -}; - -inline _LIBCPP_INLINE_VISIBILITY -int -char_traits<char32_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) -{ - for (; __n; --__n, ++__s1, ++__s2) - { - if (lt(*__s1, *__s2)) - return -1; - if (lt(*__s2, *__s1)) - return 1; - } - return 0; -} - -inline _LIBCPP_INLINE_VISIBILITY -size_t -char_traits<char32_t>::length(const char_type* __s) -{ - size_t __len = 0; - for (; !eq(*__s, char_type(0)); ++__s) - ++__len; - return __len; -} - -inline _LIBCPP_INLINE_VISIBILITY -const char32_t* -char_traits<char32_t>::find(const char_type* __s, size_t __n, const char_type& __a) -{ - for (; __n; --__n) - { - if (eq(*__s, __a)) - return __s; - ++__s; - } - return 0; -} - -inline _LIBCPP_INLINE_VISIBILITY -char32_t* -char_traits<char32_t>::move(char_type* __s1, const char_type* __s2, size_t __n) -{ - char_type* __r = __s1; - if (__s1 < __s2) - { - for (; __n; --__n, ++__s1, ++__s2) - assign(*__s1, *__s2); - } - else if (__s2 < __s1) - { - __s1 += __n; - __s2 += __n; - for (; __n; --__n) - assign(*--__s1, *--__s2); - } - return __r; -} - -inline _LIBCPP_INLINE_VISIBILITY -char32_t* -char_traits<char32_t>::copy(char_type* __s1, const char_type* __s2, size_t __n) -{ - char_type* __r = __s1; - for (; __n; --__n, ++__s1, ++__s2) - assign(*__s1, *__s2); - return __r; -} - -inline _LIBCPP_INLINE_VISIBILITY -char32_t* -char_traits<char32_t>::assign(char_type* __s, size_t __n, char_type __a) -{ - char_type* __r = __s; - for (; __n; --__n, ++__s) - assign(*__s, __a); - return __r; -} - -#endif // _LIBCPP_HAS_NO_UNICODE_CHARS - -// basic_string - -template<class _CharT, class _Traits, class _Allocator> -basic_string<_CharT, _Traits, _Allocator> -operator+(const basic_string<_CharT, _Traits, _Allocator>&, const basic_string<_CharT, _Traits, _Allocator>&); - -template<class _CharT, class _Traits, class _Allocator> -basic_string<_CharT, _Traits, _Allocator> -operator+(const _CharT*, const basic_string<_CharT,_Traits,_Allocator>&); - -template<class _CharT, class _Traits, class _Allocator> -basic_string<_CharT, _Traits, _Allocator> -operator+(_CharT, const basic_string<_CharT,_Traits,_Allocator>&); - -template<class _CharT, class _Traits, class _Allocator> -basic_string<_CharT, _Traits, _Allocator> -operator+(const basic_string<_CharT, _Traits, _Allocator>&, const _CharT*); - -template<class _CharT, class _Traits, class _Allocator> -basic_string<_CharT, _Traits, _Allocator> -operator+(const basic_string<_CharT, _Traits, _Allocator>&, _CharT); - -template <bool> -class __basic_string_common -{ -protected: - void __throw_length_error() const; - void __throw_out_of_range() const; -}; - -template <bool __b> -void -__basic_string_common<__b>::__throw_length_error() const -{ -#ifndef _LIBCPP_NO_EXCEPTIONS - throw length_error("basic_string"); -#else - assert(!"basic_string length_error"); -#endif -} - -template <bool __b> -void -__basic_string_common<__b>::__throw_out_of_range() const -{ -#ifndef _LIBCPP_NO_EXCEPTIONS - throw out_of_range("basic_string"); -#else - assert(!"basic_string out_of_range"); -#endif -} - -extern template class __basic_string_common<true>; - -template<class _CharT, class _Traits, class _Allocator> -class _LIBCPP_VISIBLE basic_string - : private __basic_string_common<true> -{ -public: - typedef basic_string __self; - typedef _Traits traits_type; - typedef typename traits_type::char_type value_type; - typedef _Allocator allocator_type; - typedef allocator_traits<allocator_type> __alloc_traits; - typedef typename __alloc_traits::size_type size_type; - typedef typename __alloc_traits::difference_type difference_type; - typedef typename allocator_type::reference reference; - typedef typename allocator_type::const_reference const_reference; - typedef typename __alloc_traits::pointer pointer; - typedef typename __alloc_traits::const_pointer const_pointer; |