Index: projects/clang600-import/contrib/libc++/include/sstream =================================================================== --- projects/clang600-import/contrib/libc++/include/sstream (revision 327138) +++ projects/clang600-import/contrib/libc++/include/sstream (revision 327139) @@ -1,985 +1,986 @@ // -*- C++ -*- //===--------------------------- sstream ----------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef _LIBCPP_SSTREAM #define _LIBCPP_SSTREAM /* sstream synopsis template , class Allocator = allocator > class basic_stringbuf : public basic_streambuf { public: typedef charT char_type; typedef traits traits_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; typedef Allocator allocator_type; // 27.8.1.1 Constructors: explicit basic_stringbuf(ios_base::openmode which = ios_base::in | ios_base::out); explicit basic_stringbuf(const basic_string& str, ios_base::openmode which = ios_base::in | ios_base::out); basic_stringbuf(basic_stringbuf&& rhs); // 27.8.1.2 Assign and swap: basic_stringbuf& operator=(basic_stringbuf&& rhs); void swap(basic_stringbuf& rhs); // 27.8.1.3 Get and set: basic_string str() const; void str(const basic_string& s); protected: // 27.8.1.4 Overridden virtual functions: virtual int_type underflow(); virtual int_type pbackfail(int_type c = traits_type::eof()); virtual int_type overflow (int_type c = traits_type::eof()); virtual basic_streambuf* setbuf(char_type*, streamsize); virtual pos_type seekoff(off_type off, ios_base::seekdir way, ios_base::openmode which = ios_base::in | ios_base::out); virtual pos_type seekpos(pos_type sp, ios_base::openmode which = ios_base::in | ios_base::out); }; template void swap(basic_stringbuf& x, basic_stringbuf& y); typedef basic_stringbuf stringbuf; typedef basic_stringbuf wstringbuf; template , class Allocator = allocator > class basic_istringstream : public basic_istream { public: typedef charT char_type; typedef traits traits_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; typedef Allocator allocator_type; // 27.8.2.1 Constructors: explicit basic_istringstream(ios_base::openmode which = ios_base::in); explicit basic_istringstream(const basic_string& str, ios_base::openmode which = ios_base::in); basic_istringstream(basic_istringstream&& rhs); // 27.8.2.2 Assign and swap: basic_istringstream& operator=(basic_istringstream&& rhs); void swap(basic_istringstream& rhs); // 27.8.2.3 Members: basic_stringbuf* rdbuf() const; basic_string str() const; void str(const basic_string& s); }; template void swap(basic_istringstream& x, basic_istringstream& y); typedef basic_istringstream istringstream; typedef basic_istringstream wistringstream; template , class Allocator = allocator > class basic_ostringstream : public basic_ostream { public: // types: typedef charT char_type; typedef traits traits_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; typedef Allocator allocator_type; // 27.8.3.1 Constructors/destructor: explicit basic_ostringstream(ios_base::openmode which = ios_base::out); explicit basic_ostringstream(const basic_string& str, ios_base::openmode which = ios_base::out); basic_ostringstream(basic_ostringstream&& rhs); // 27.8.3.2 Assign/swap: basic_ostringstream& operator=(basic_ostringstream&& rhs); void swap(basic_ostringstream& rhs); // 27.8.3.3 Members: basic_stringbuf* rdbuf() const; basic_string str() const; void str(const basic_string& s); }; template void swap(basic_ostringstream& x, basic_ostringstream& y); typedef basic_ostringstream ostringstream; typedef basic_ostringstream wostringstream; template , class Allocator = allocator > class basic_stringstream : public basic_iostream { public: // types: typedef charT char_type; typedef traits traits_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; typedef Allocator allocator_type; // constructors/destructor explicit basic_stringstream(ios_base::openmode which = ios_base::out|ios_base::in); explicit basic_stringstream(const basic_string& str, ios_base::openmode which = ios_base::out|ios_base::in); basic_stringstream(basic_stringstream&& rhs); // 27.8.5.1 Assign/swap: basic_stringstream& operator=(basic_stringstream&& rhs); void swap(basic_stringstream& rhs); // Members: basic_stringbuf* rdbuf() const; basic_string str() const; void str(const basic_string& str); }; template void swap(basic_stringstream& x, basic_stringstream& y); typedef basic_stringstream stringstream; typedef basic_stringstream wstringstream; } // std */ #include <__config> #include #include #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_PUSH_MACROS #include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD // basic_stringbuf template class _LIBCPP_TEMPLATE_VIS basic_stringbuf : public basic_streambuf<_CharT, _Traits> { public: typedef _CharT char_type; typedef _Traits traits_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; typedef _Allocator allocator_type; typedef basic_string string_type; private: string_type __str_; mutable char_type* __hm_; ios_base::openmode __mode_; public: // 27.8.1.1 Constructors: inline _LIBCPP_INLINE_VISIBILITY explicit basic_stringbuf(ios_base::openmode __wch = ios_base::in | ios_base::out); inline _LIBCPP_INLINE_VISIBILITY explicit basic_stringbuf(const string_type& __s, ios_base::openmode __wch = ios_base::in | ios_base::out); #ifndef _LIBCPP_CXX03_LANG basic_stringbuf(basic_stringbuf&& __rhs); // 27.8.1.2 Assign and swap: basic_stringbuf& operator=(basic_stringbuf&& __rhs); #endif void swap(basic_stringbuf& __rhs); // 27.8.1.3 Get and set: string_type str() const; void str(const string_type& __s); protected: // 27.8.1.4 Overridden virtual functions: virtual int_type underflow(); virtual int_type pbackfail(int_type __c = traits_type::eof()); virtual int_type overflow (int_type __c = traits_type::eof()); virtual pos_type seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __wch = ios_base::in | ios_base::out); inline _LIBCPP_INLINE_VISIBILITY virtual pos_type seekpos(pos_type __sp, ios_base::openmode __wch = ios_base::in | ios_base::out); }; template basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(ios_base::openmode __wch) : __hm_(0), __mode_(__wch) { } template basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(const string_type& __s, ios_base::openmode __wch) : __str_(__s.get_allocator()), __hm_(0), __mode_(__wch) { str(__s); } #ifndef _LIBCPP_CXX03_LANG template basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(basic_stringbuf&& __rhs) : __mode_(__rhs.__mode_) { char_type* __p = const_cast(__rhs.__str_.data()); ptrdiff_t __binp = -1; ptrdiff_t __ninp = -1; ptrdiff_t __einp = -1; if (__rhs.eback() != nullptr) { __binp = __rhs.eback() - __p; __ninp = __rhs.gptr() - __p; __einp = __rhs.egptr() - __p; } ptrdiff_t __bout = -1; ptrdiff_t __nout = -1; ptrdiff_t __eout = -1; if (__rhs.pbase() != nullptr) { __bout = __rhs.pbase() - __p; __nout = __rhs.pptr() - __p; __eout = __rhs.epptr() - __p; } ptrdiff_t __hm = __rhs.__hm_ == nullptr ? -1 : __rhs.__hm_ - __p; __str_ = _VSTD::move(__rhs.__str_); __p = const_cast(__str_.data()); if (__binp != -1) this->setg(__p + __binp, __p + __ninp, __p + __einp); if (__bout != -1) { this->setp(__p + __bout, __p + __eout); this->__pbump(__nout); } __hm_ = __hm == -1 ? nullptr : __p + __hm; __p = const_cast(__rhs.__str_.data()); __rhs.setg(__p, __p, __p); __rhs.setp(__p, __p); __rhs.__hm_ = __p; this->pubimbue(__rhs.getloc()); } template basic_stringbuf<_CharT, _Traits, _Allocator>& basic_stringbuf<_CharT, _Traits, _Allocator>::operator=(basic_stringbuf&& __rhs) { char_type* __p = const_cast(__rhs.__str_.data()); ptrdiff_t __binp = -1; ptrdiff_t __ninp = -1; ptrdiff_t __einp = -1; if (__rhs.eback() != nullptr) { __binp = __rhs.eback() - __p; __ninp = __rhs.gptr() - __p; __einp = __rhs.egptr() - __p; } ptrdiff_t __bout = -1; ptrdiff_t __nout = -1; ptrdiff_t __eout = -1; if (__rhs.pbase() != nullptr) { __bout = __rhs.pbase() - __p; __nout = __rhs.pptr() - __p; __eout = __rhs.epptr() - __p; } ptrdiff_t __hm = __rhs.__hm_ == nullptr ? -1 : __rhs.__hm_ - __p; __str_ = _VSTD::move(__rhs.__str_); __p = const_cast(__str_.data()); if (__binp != -1) this->setg(__p + __binp, __p + __ninp, __p + __einp); else this->setg(nullptr, nullptr, nullptr); if (__bout != -1) { this->setp(__p + __bout, __p + __eout); this->__pbump(__nout); } else this->setp(nullptr, nullptr); __hm_ = __hm == -1 ? nullptr : __p + __hm; __mode_ = __rhs.__mode_; __p = const_cast(__rhs.__str_.data()); __rhs.setg(__p, __p, __p); __rhs.setp(__p, __p); __rhs.__hm_ = __p; this->pubimbue(__rhs.getloc()); return *this; } #endif // _LIBCPP_CXX03_LANG template void basic_stringbuf<_CharT, _Traits, _Allocator>::swap(basic_stringbuf& __rhs) { char_type* __p = const_cast(__rhs.__str_.data()); ptrdiff_t __rbinp = -1; ptrdiff_t __rninp = -1; ptrdiff_t __reinp = -1; if (__rhs.eback() != nullptr) { __rbinp = __rhs.eback() - __p; __rninp = __rhs.gptr() - __p; __reinp = __rhs.egptr() - __p; } ptrdiff_t __rbout = -1; ptrdiff_t __rnout = -1; ptrdiff_t __reout = -1; if (__rhs.pbase() != nullptr) { __rbout = __rhs.pbase() - __p; __rnout = __rhs.pptr() - __p; __reout = __rhs.epptr() - __p; } ptrdiff_t __rhm = __rhs.__hm_ == nullptr ? -1 : __rhs.__hm_ - __p; __p = const_cast(__str_.data()); ptrdiff_t __lbinp = -1; ptrdiff_t __lninp = -1; ptrdiff_t __leinp = -1; if (this->eback() != nullptr) { __lbinp = this->eback() - __p; __lninp = this->gptr() - __p; __leinp = this->egptr() - __p; } ptrdiff_t __lbout = -1; ptrdiff_t __lnout = -1; ptrdiff_t __leout = -1; if (this->pbase() != nullptr) { __lbout = this->pbase() - __p; __lnout = this->pptr() - __p; __leout = this->epptr() - __p; } ptrdiff_t __lhm = __hm_ == nullptr ? -1 : __hm_ - __p; _VSTD::swap(__mode_, __rhs.__mode_); __str_.swap(__rhs.__str_); __p = const_cast(__str_.data()); if (__rbinp != -1) this->setg(__p + __rbinp, __p + __rninp, __p + __reinp); else this->setg(nullptr, nullptr, nullptr); if (__rbout != -1) { this->setp(__p + __rbout, __p + __reout); this->__pbump(__rnout); } else this->setp(nullptr, nullptr); __hm_ = __rhm == -1 ? nullptr : __p + __rhm; __p = const_cast(__rhs.__str_.data()); if (__lbinp != -1) __rhs.setg(__p + __lbinp, __p + __lninp, __p + __leinp); else __rhs.setg(nullptr, nullptr, nullptr); if (__lbout != -1) { __rhs.setp(__p + __lbout, __p + __leout); __rhs.__pbump(__lnout); } else __rhs.setp(nullptr, nullptr); __rhs.__hm_ = __lhm == -1 ? nullptr : __p + __lhm; locale __tl = __rhs.getloc(); __rhs.pubimbue(this->getloc()); this->pubimbue(__tl); } template inline _LIBCPP_INLINE_VISIBILITY void swap(basic_stringbuf<_CharT, _Traits, _Allocator>& __x, basic_stringbuf<_CharT, _Traits, _Allocator>& __y) { __x.swap(__y); } template basic_string<_CharT, _Traits, _Allocator> basic_stringbuf<_CharT, _Traits, _Allocator>::str() const { if (__mode_ & ios_base::out) { if (__hm_ < this->pptr()) __hm_ = this->pptr(); return string_type(this->pbase(), __hm_, __str_.get_allocator()); } else if (__mode_ & ios_base::in) return string_type(this->eback(), this->egptr(), __str_.get_allocator()); return string_type(__str_.get_allocator()); } template void basic_stringbuf<_CharT, _Traits, _Allocator>::str(const string_type& __s) { __str_ = __s; __hm_ = 0; if (__mode_ & ios_base::in) { __hm_ = const_cast(__str_.data()) + __str_.size(); this->setg(const_cast(__str_.data()), const_cast(__str_.data()), __hm_); } if (__mode_ & ios_base::out) { typename string_type::size_type __sz = __str_.size(); __hm_ = const_cast(__str_.data()) + __sz; __str_.resize(__str_.capacity()); this->setp(const_cast(__str_.data()), const_cast(__str_.data()) + __str_.size()); if (__mode_ & (ios_base::app | ios_base::ate)) { while (__sz > INT_MAX) { this->pbump(INT_MAX); __sz -= INT_MAX; } if (__sz > 0) this->pbump(__sz); } } } template typename basic_stringbuf<_CharT, _Traits, _Allocator>::int_type basic_stringbuf<_CharT, _Traits, _Allocator>::underflow() { if (__hm_ < this->pptr()) __hm_ = this->pptr(); if (__mode_ & ios_base::in) { if (this->egptr() < __hm_) this->setg(this->eback(), this->gptr(), __hm_); if (this->gptr() < this->egptr()) return traits_type::to_int_type(*this->gptr()); } return traits_type::eof(); } template typename basic_stringbuf<_CharT, _Traits, _Allocator>::int_type basic_stringbuf<_CharT, _Traits, _Allocator>::pbackfail(int_type __c) { if (__hm_ < this->pptr()) __hm_ = this->pptr(); if (this->eback() < this->gptr()) { if (traits_type::eq_int_type(__c, traits_type::eof())) { this->setg(this->eback(), this->gptr()-1, __hm_); return traits_type::not_eof(__c); } if ((__mode_ & ios_base::out) || traits_type::eq(traits_type::to_char_type(__c), this->gptr()[-1])) { this->setg(this->eback(), this->gptr()-1, __hm_); *this->gptr() = traits_type::to_char_type(__c); return __c; } } return traits_type::eof(); } template typename basic_stringbuf<_CharT, _Traits, _Allocator>::int_type basic_stringbuf<_CharT, _Traits, _Allocator>::overflow(int_type __c) { if (!traits_type::eq_int_type(__c, traits_type::eof())) { ptrdiff_t __ninp = this->gptr() - this->eback(); if (this->pptr() == this->epptr()) { if (!(__mode_ & ios_base::out)) return traits_type::eof(); #ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS ptrdiff_t __nout = this->pptr() - this->pbase(); ptrdiff_t __hm = __hm_ - this->pbase(); __str_.push_back(char_type()); __str_.resize(__str_.capacity()); char_type* __p = const_cast(__str_.data()); this->setp(__p, __p + __str_.size()); this->__pbump(__nout); __hm_ = this->pbase() + __hm; #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { return traits_type::eof(); } #endif // _LIBCPP_NO_EXCEPTIONS } __hm_ = _VSTD::max(this->pptr() + 1, __hm_); if (__mode_ & ios_base::in) { char_type* __p = const_cast(__str_.data()); this->setg(__p, __p + __ninp, __hm_); } return this->sputc(__c); } return traits_type::not_eof(__c); } template typename basic_stringbuf<_CharT, _Traits, _Allocator>::pos_type basic_stringbuf<_CharT, _Traits, _Allocator>::seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __wch) { if (__hm_ < this->pptr()) __hm_ = this->pptr(); if ((__wch & (ios_base::in | ios_base::out)) == 0) return pos_type(-1); if ((__wch & (ios_base::in | ios_base::out)) == (ios_base::in | ios_base::out) && __way == ios_base::cur) return pos_type(-1); + const ptrdiff_t __hm = __hm_ == nullptr ? 0 : __hm_ - __str_.data(); off_type __noff; switch (__way) { case ios_base::beg: __noff = 0; break; case ios_base::cur: if (__wch & ios_base::in) __noff = this->gptr() - this->eback(); else __noff = this->pptr() - this->pbase(); break; case ios_base::end: - __noff = __hm_ - __str_.data(); + __noff = __hm; break; default: return pos_type(-1); } __noff += __off; - if (__noff < 0 || __hm_ - __str_.data() < __noff) + if (__noff < 0 || __hm < __noff) return pos_type(-1); if (__noff != 0) { if ((__wch & ios_base::in) && this->gptr() == 0) return pos_type(-1); if ((__wch & ios_base::out) && this->pptr() == 0) return pos_type(-1); } if (__wch & ios_base::in) this->setg(this->eback(), this->eback() + __noff, __hm_); if (__wch & ios_base::out) { this->setp(this->pbase(), this->epptr()); this->pbump(__noff); } return pos_type(__noff); } template typename basic_stringbuf<_CharT, _Traits, _Allocator>::pos_type basic_stringbuf<_CharT, _Traits, _Allocator>::seekpos(pos_type __sp, ios_base::openmode __wch) { return seekoff(__sp, ios_base::beg, __wch); } // basic_istringstream template class _LIBCPP_TEMPLATE_VIS basic_istringstream : public basic_istream<_CharT, _Traits> { public: typedef _CharT char_type; typedef _Traits traits_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; typedef _Allocator allocator_type; typedef basic_string string_type; private: basic_stringbuf __sb_; public: // 27.8.2.1 Constructors: inline _LIBCPP_INLINE_VISIBILITY explicit basic_istringstream(ios_base::openmode __wch = ios_base::in); inline _LIBCPP_INLINE_VISIBILITY explicit basic_istringstream(const string_type& __s, ios_base::openmode __wch = ios_base::in); #ifndef _LIBCPP_CXX03_LANG inline _LIBCPP_INLINE_VISIBILITY basic_istringstream(basic_istringstream&& __rhs); // 27.8.2.2 Assign and swap: basic_istringstream& operator=(basic_istringstream&& __rhs); #endif // _LIBCPP_CXX03_LANG inline _LIBCPP_INLINE_VISIBILITY void swap(basic_istringstream& __rhs); // 27.8.2.3 Members: inline _LIBCPP_INLINE_VISIBILITY basic_stringbuf* rdbuf() const; inline _LIBCPP_INLINE_VISIBILITY string_type str() const; inline _LIBCPP_INLINE_VISIBILITY void str(const string_type& __s); }; template basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(ios_base::openmode __wch) : basic_istream<_CharT, _Traits>(&__sb_), __sb_(__wch | ios_base::in) { } template basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(const string_type& __s, ios_base::openmode __wch) : basic_istream<_CharT, _Traits>(&__sb_), __sb_(__s, __wch | ios_base::in) { } #ifndef _LIBCPP_CXX03_LANG template basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(basic_istringstream&& __rhs) : basic_istream<_CharT, _Traits>(_VSTD::move(__rhs)), __sb_(_VSTD::move(__rhs.__sb_)) { basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_); } template basic_istringstream<_CharT, _Traits, _Allocator>& basic_istringstream<_CharT, _Traits, _Allocator>::operator=(basic_istringstream&& __rhs) { basic_istream::operator=(_VSTD::move(__rhs)); __sb_ = _VSTD::move(__rhs.__sb_); return *this; } #endif // _LIBCPP_CXX03_LANG template void basic_istringstream<_CharT, _Traits, _Allocator>::swap(basic_istringstream& __rhs) { basic_istream::swap(__rhs); __sb_.swap(__rhs.__sb_); } template inline _LIBCPP_INLINE_VISIBILITY void swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x, basic_istringstream<_CharT, _Traits, _Allocator>& __y) { __x.swap(__y); } template basic_stringbuf<_CharT, _Traits, _Allocator>* basic_istringstream<_CharT, _Traits, _Allocator>::rdbuf() const { return const_cast*>(&__sb_); } template basic_string<_CharT, _Traits, _Allocator> basic_istringstream<_CharT, _Traits, _Allocator>::str() const { return __sb_.str(); } template void basic_istringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s) { __sb_.str(__s); } // basic_ostringstream template class _LIBCPP_TEMPLATE_VIS basic_ostringstream : public basic_ostream<_CharT, _Traits> { public: typedef _CharT char_type; typedef _Traits traits_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; typedef _Allocator allocator_type; typedef basic_string string_type; private: basic_stringbuf __sb_; public: // 27.8.2.1 Constructors: inline _LIBCPP_INLINE_VISIBILITY explicit basic_ostringstream(ios_base::openmode __wch = ios_base::out); inline _LIBCPP_INLINE_VISIBILITY explicit basic_ostringstream(const string_type& __s, ios_base::openmode __wch = ios_base::out); #ifndef _LIBCPP_CXX03_LANG inline _LIBCPP_INLINE_VISIBILITY basic_ostringstream(basic_ostringstream&& __rhs); // 27.8.2.2 Assign and swap: basic_ostringstream& operator=(basic_ostringstream&& __rhs); #endif // _LIBCPP_CXX03_LANG inline _LIBCPP_INLINE_VISIBILITY void swap(basic_ostringstream& __rhs); // 27.8.2.3 Members: inline _LIBCPP_INLINE_VISIBILITY basic_stringbuf* rdbuf() const; inline _LIBCPP_INLINE_VISIBILITY string_type str() const; inline _LIBCPP_INLINE_VISIBILITY void str(const string_type& __s); }; template basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(ios_base::openmode __wch) : basic_ostream<_CharT, _Traits>(&__sb_), __sb_(__wch | ios_base::out) { } template basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(const string_type& __s, ios_base::openmode __wch) : basic_ostream<_CharT, _Traits>(&__sb_), __sb_(__s, __wch | ios_base::out) { } #ifndef _LIBCPP_CXX03_LANG template basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(basic_ostringstream&& __rhs) : basic_ostream<_CharT, _Traits>(_VSTD::move(__rhs)), __sb_(_VSTD::move(__rhs.__sb_)) { basic_ostream<_CharT, _Traits>::set_rdbuf(&__sb_); } template basic_ostringstream<_CharT, _Traits, _Allocator>& basic_ostringstream<_CharT, _Traits, _Allocator>::operator=(basic_ostringstream&& __rhs) { basic_ostream::operator=(_VSTD::move(__rhs)); __sb_ = _VSTD::move(__rhs.__sb_); return *this; } #endif // _LIBCPP_CXX03_LANG template void basic_ostringstream<_CharT, _Traits, _Allocator>::swap(basic_ostringstream& __rhs) { basic_ostream::swap(__rhs); __sb_.swap(__rhs.__sb_); } template inline _LIBCPP_INLINE_VISIBILITY void swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x, basic_ostringstream<_CharT, _Traits, _Allocator>& __y) { __x.swap(__y); } template basic_stringbuf<_CharT, _Traits, _Allocator>* basic_ostringstream<_CharT, _Traits, _Allocator>::rdbuf() const { return const_cast*>(&__sb_); } template basic_string<_CharT, _Traits, _Allocator> basic_ostringstream<_CharT, _Traits, _Allocator>::str() const { return __sb_.str(); } template void basic_ostringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s) { __sb_.str(__s); } // basic_stringstream template class _LIBCPP_TEMPLATE_VIS basic_stringstream : public basic_iostream<_CharT, _Traits> { public: typedef _CharT char_type; typedef _Traits traits_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; typedef _Allocator allocator_type; typedef basic_string string_type; private: basic_stringbuf __sb_; public: // 27.8.2.1 Constructors: inline _LIBCPP_INLINE_VISIBILITY explicit basic_stringstream(ios_base::openmode __wch = ios_base::in | ios_base::out); inline _LIBCPP_INLINE_VISIBILITY explicit basic_stringstream(const string_type& __s, ios_base::openmode __wch = ios_base::in | ios_base::out); #ifndef _LIBCPP_CXX03_LANG inline _LIBCPP_INLINE_VISIBILITY basic_stringstream(basic_stringstream&& __rhs); // 27.8.2.2 Assign and swap: basic_stringstream& operator=(basic_stringstream&& __rhs); #endif // _LIBCPP_CXX03_LANG inline _LIBCPP_INLINE_VISIBILITY void swap(basic_stringstream& __rhs); // 27.8.2.3 Members: inline _LIBCPP_INLINE_VISIBILITY basic_stringbuf* rdbuf() const; inline _LIBCPP_INLINE_VISIBILITY string_type str() const; inline _LIBCPP_INLINE_VISIBILITY void str(const string_type& __s); }; template basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(ios_base::openmode __wch) : basic_iostream<_CharT, _Traits>(&__sb_), __sb_(__wch) { } template basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(const string_type& __s, ios_base::openmode __wch) : basic_iostream<_CharT, _Traits>(&__sb_), __sb_(__s, __wch) { } #ifndef _LIBCPP_CXX03_LANG template basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(basic_stringstream&& __rhs) : basic_iostream<_CharT, _Traits>(_VSTD::move(__rhs)), __sb_(_VSTD::move(__rhs.__sb_)) { basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_); } template basic_stringstream<_CharT, _Traits, _Allocator>& basic_stringstream<_CharT, _Traits, _Allocator>::operator=(basic_stringstream&& __rhs) { basic_iostream::operator=(_VSTD::move(__rhs)); __sb_ = _VSTD::move(__rhs.__sb_); return *this; } #endif // _LIBCPP_CXX03_LANG template void basic_stringstream<_CharT, _Traits, _Allocator>::swap(basic_stringstream& __rhs) { basic_iostream::swap(__rhs); __sb_.swap(__rhs.__sb_); } template inline _LIBCPP_INLINE_VISIBILITY void swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x, basic_stringstream<_CharT, _Traits, _Allocator>& __y) { __x.swap(__y); } template basic_stringbuf<_CharT, _Traits, _Allocator>* basic_stringstream<_CharT, _Traits, _Allocator>::rdbuf() const { return const_cast*>(&__sb_); } template basic_string<_CharT, _Traits, _Allocator> basic_stringstream<_CharT, _Traits, _Allocator>::str() const { return __sb_.str(); } template void basic_stringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s) { __sb_.str(__s); } _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS #endif // _LIBCPP_SSTREAM Index: projects/clang600-import/contrib/libc++/include/string_view =================================================================== --- projects/clang600-import/contrib/libc++/include/string_view (revision 327138) +++ projects/clang600-import/contrib/libc++/include/string_view (revision 327139) @@ -1,825 +1,825 @@ // -*- C++ -*- //===------------------------ string_view ---------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef _LIBCPP_STRING_VIEW #define _LIBCPP_STRING_VIEW /* string_view synopsis namespace std { // 7.2, Class template basic_string_view template> class basic_string_view; // 7.9, basic_string_view non-member comparison functions template constexpr bool operator==(basic_string_view x, basic_string_view y) noexcept; template constexpr bool operator!=(basic_string_view x, basic_string_view y) noexcept; template constexpr bool operator< (basic_string_view x, basic_string_view y) noexcept; template constexpr bool operator> (basic_string_view x, basic_string_view y) noexcept; template constexpr bool operator<=(basic_string_view x, basic_string_view y) noexcept; template constexpr bool operator>=(basic_string_view x, basic_string_view y) noexcept; // see below, sufficient additional overloads of comparison functions // 7.10, Inserters and extractors template basic_ostream& operator<<(basic_ostream& os, basic_string_view str); // basic_string_view typedef names typedef basic_string_view string_view; typedef basic_string_view u16string_view; typedef basic_string_view u32string_view; typedef basic_string_view wstring_view; template> class basic_string_view { public: // types typedef traits traits_type; typedef charT value_type; typedef charT* pointer; typedef const charT* const_pointer; typedef charT& reference; typedef const charT& const_reference; typedef implementation-defined const_iterator; typedef const_iterator iterator; typedef reverse_iterator const_reverse_iterator; typedef const_reverse_iterator reverse_iterator; typedef size_t size_type; typedef ptrdiff_t difference_type; static constexpr size_type npos = size_type(-1); // 7.3, basic_string_view constructors and assignment operators constexpr basic_string_view() noexcept; constexpr basic_string_view(const basic_string_view&) noexcept = default; basic_string_view& operator=(const basic_string_view&) noexcept = default; template constexpr basic_string_view(const charT* str); constexpr basic_string_view(const charT* str, size_type len); // 7.4, basic_string_view iterator support constexpr const_iterator begin() const noexcept; constexpr const_iterator end() const noexcept; constexpr const_iterator cbegin() const noexcept; constexpr const_iterator cend() const noexcept; const_reverse_iterator rbegin() const noexcept; const_reverse_iterator rend() const noexcept; const_reverse_iterator crbegin() const noexcept; const_reverse_iterator crend() const noexcept; // 7.5, basic_string_view capacity constexpr size_type size() const noexcept; constexpr size_type length() const noexcept; constexpr size_type max_size() const noexcept; constexpr bool empty() const noexcept; // 7.6, basic_string_view element access constexpr const_reference operator[](size_type pos) const; constexpr const_reference at(size_type pos) const; constexpr const_reference front() const; constexpr const_reference back() const; constexpr const_pointer data() const noexcept; // 7.7, basic_string_view modifiers constexpr void remove_prefix(size_type n); constexpr void remove_suffix(size_type n); constexpr void swap(basic_string_view& s) noexcept; size_type copy(charT* s, size_type n, size_type pos = 0) const; constexpr basic_string_view substr(size_type pos = 0, size_type n = npos) const; constexpr int compare(basic_string_view s) const noexcept; constexpr int compare(size_type pos1, size_type n1, basic_string_view s) const; constexpr int compare(size_type pos1, size_type n1, basic_string_view s, size_type pos2, size_type n2) const; constexpr int compare(const charT* s) const; constexpr int compare(size_type pos1, size_type n1, const charT* s) const; constexpr int compare(size_type pos1, size_type n1, const charT* s, size_type n2) const; constexpr size_type find(basic_string_view s, size_type pos = 0) const noexcept; constexpr size_type find(charT c, size_type pos = 0) const noexcept; constexpr size_type find(const charT* s, size_type pos, size_type n) const; constexpr size_type find(const charT* s, size_type pos = 0) const; constexpr size_type rfind(basic_string_view s, size_type pos = npos) const noexcept; constexpr size_type rfind(charT c, size_type pos = npos) const noexcept; constexpr size_type rfind(const charT* s, size_type pos, size_type n) const; constexpr size_type rfind(const charT* s, size_type pos = npos) const; constexpr size_type find_first_of(basic_string_view s, size_type pos = 0) const noexcept; constexpr size_type find_first_of(charT c, size_type pos = 0) const noexcept; constexpr size_type find_first_of(const charT* s, size_type pos, size_type n) const; constexpr size_type find_first_of(const charT* s, size_type pos = 0) const; constexpr size_type find_last_of(basic_string_view s, size_type pos = npos) const noexcept; constexpr size_type find_last_of(charT c, size_type pos = npos) const noexcept; constexpr size_type find_last_of(const charT* s, size_type pos, size_type n) const; constexpr size_type find_last_of(const charT* s, size_type pos = npos) const; constexpr size_type find_first_not_of(basic_string_view s, size_type pos = 0) const noexcept; constexpr size_type find_first_not_of(charT c, size_type pos = 0) const noexcept; constexpr size_type find_first_not_of(const charT* s, size_type pos, size_type n) const; constexpr size_type find_first_not_of(const charT* s, size_type pos = 0) const; constexpr size_type find_last_not_of(basic_string_view s, size_type pos = npos) const noexcept; constexpr size_type find_last_not_of(charT c, size_type pos = npos) const noexcept; constexpr size_type find_last_not_of(const charT* s, size_type pos, size_type n) const; constexpr size_type find_last_not_of(const charT* s, size_type pos = npos) const; constexpr bool starts_with(basic_string_view s) const noexcept; // C++2a constexpr bool starts_with(charT c) const noexcept; // C++2a constexpr bool starts_with(const charT* s) const; // C++2a constexpr bool ends_with(basic_string_view s) const noexcept; // C++2a constexpr bool ends_with(charT c) const noexcept; // C++2a constexpr bool ends_with(const charT* s) const; // C++2a private: const_pointer data_; // exposition only size_type size_; // exposition only }; // 7.11, Hash support template struct hash; template <> struct hash; template <> struct hash; template <> struct hash; template <> struct hash; constexpr basic_string_view operator "" sv( const char *str, size_t len ) noexcept; constexpr basic_string_view operator "" sv( const wchar_t *str, size_t len ) noexcept; constexpr basic_string_view operator "" sv( const char16_t *str, size_t len ) noexcept; constexpr basic_string_view operator "" sv( const char32_t *str, size_t len ) noexcept; } // namespace std */ #include <__config> #include <__string> #include #include #include #include #include <__debug> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif _LIBCPP_PUSH_MACROS #include <__undef_macros> _LIBCPP_BEGIN_NAMESPACE_STD template > class _LIBCPP_TEMPLATE_VIS basic_string_view { public: // types typedef _Traits traits_type; typedef _CharT value_type; - typedef const _CharT* pointer; + typedef _CharT* pointer; typedef const _CharT* const_pointer; - typedef const _CharT& reference; + typedef _CharT& reference; typedef const _CharT& const_reference; typedef const_pointer const_iterator; // See [string.view.iterators] typedef const_iterator iterator; typedef _VSTD::reverse_iterator const_reverse_iterator; typedef const_reverse_iterator reverse_iterator; typedef size_t size_type; typedef ptrdiff_t difference_type; static _LIBCPP_CONSTEXPR const size_type npos = -1; // size_type(-1); static_assert(is_pod::value, "Character type of basic_string_view must be a POD"); static_assert((is_same<_CharT, typename traits_type::char_type>::value), "traits_type::char_type must be the same type as CharT"); // [string.view.cons], construct/copy _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY basic_string_view() _NOEXCEPT : __data (nullptr), __size(0) {} _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY basic_string_view(const basic_string_view&) _NOEXCEPT = default; _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY basic_string_view& operator=(const basic_string_view&) _NOEXCEPT = default; _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY basic_string_view(const _CharT* __s, size_type __len) _NOEXCEPT : __data(__s), __size(__len) { // #if _LIBCPP_STD_VER > 11 // _LIBCPP_ASSERT(__len == 0 || __s != nullptr, "string_view::string_view(_CharT *, size_t): received nullptr"); // #endif } _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY basic_string_view(const _CharT* __s) : __data(__s), __size(_Traits::length(__s)) {} // [string.view.iterators], iterators _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT { return cbegin(); } _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT { return cend(); } _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_iterator cbegin() const _NOEXCEPT { return __data; } _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_iterator cend() const _NOEXCEPT { return __data + __size; } _LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(cend()); } _LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY const_reverse_iterator rend() const _NOEXCEPT { return const_reverse_iterator(cbegin()); } _LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY const_reverse_iterator crbegin() const _NOEXCEPT { return const_reverse_iterator(cend()); } _LIBCPP_CONSTEXPR_AFTER_CXX14 _LIBCPP_INLINE_VISIBILITY const_reverse_iterator crend() const _NOEXCEPT { return const_reverse_iterator(cbegin()); } // [string.view.capacity], capacity _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY size_type size() const _NOEXCEPT { return __size; } _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY size_type length() const _NOEXCEPT { return __size; } _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT { return numeric_limits::max(); } _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { return __size == 0; } // [string.view.access], element access _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __pos) const _NOEXCEPT { return __data[__pos]; } _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_reference at(size_type __pos) const { return __pos >= size() ? (__throw_out_of_range("string_view::at"), __data[0]) : __data[__pos]; } _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_reference front() const { return _LIBCPP_ASSERT(!empty(), "string_view::front(): string is empty"), __data[0]; } _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_reference back() const { return _LIBCPP_ASSERT(!empty(), "string_view::back(): string is empty"), __data[__size-1]; } _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY const_pointer data() const _NOEXCEPT { return __data; } // [string.view.modifiers], modifiers: _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY void remove_prefix(size_type __n) _NOEXCEPT { _LIBCPP_ASSERT(__n <= size(), "remove_prefix() can't remove more than size()"); __data += __n; __size -= __n; } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY void remove_suffix(size_type __n) _NOEXCEPT { _LIBCPP_ASSERT(__n <= size(), "remove_suffix() can't remove more than size()"); __size -= __n; } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY void swap(basic_string_view& __other) _NOEXCEPT { const value_type *__p = __data; __data = __other.__data; __other.__data = __p; size_type __sz = __size; __size = __other.__size; __other.__size = __sz; } _LIBCPP_INLINE_VISIBILITY size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const { if (__pos > size()) __throw_out_of_range("string_view::copy"); size_type __rlen = _VSTD::min(__n, size() - __pos); _Traits::copy(__s, data() + __pos, __rlen); return __rlen; } _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY basic_string_view substr(size_type __pos = 0, size_type __n = npos) const { return __pos > size() ? (__throw_out_of_range("string_view::substr"), basic_string_view()) : basic_string_view(data() + __pos, _VSTD::min(__n, size() - __pos)); } _LIBCPP_CONSTEXPR_AFTER_CXX11 int compare(basic_string_view __sv) const _NOEXCEPT { size_type __rlen = _VSTD::min( size(), __sv.size()); int __retval = _Traits::compare(data(), __sv.data(), __rlen); if ( __retval == 0 ) // first __rlen chars matched __retval = size() == __sv.size() ? 0 : ( size() < __sv.size() ? -1 : 1 ); return __retval; } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY int compare(size_type __pos1, size_type __n1, basic_string_view __sv) const { return substr(__pos1, __n1).compare(__sv); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY int compare( size_type __pos1, size_type __n1, basic_string_view __sv, size_type __pos2, size_type __n2) const { return substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2)); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY int compare(const _CharT* __s) const _NOEXCEPT { return compare(basic_string_view(__s)); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY int compare(size_type __pos1, size_type __n1, const _CharT* __s) const { return substr(__pos1, __n1).compare(basic_string_view(__s)); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY int compare(size_type __pos1, size_type __n1, const _CharT* __s, size_type __n2) const { return substr(__pos1, __n1).compare(basic_string_view(__s, __n2)); } // find _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT { _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): received nullptr"); return __str_find (data(), size(), __s.data(), __pos, __s.size()); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find(_CharT __c, size_type __pos = 0) const _NOEXCEPT { return __str_find (data(), size(), __c, __pos); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find(const _CharT* __s, size_type __pos, size_type __n) const { _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find(): received nullptr"); return __str_find (data(), size(), __s, __pos, __n); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find(const _CharT* __s, size_type __pos = 0) const { _LIBCPP_ASSERT(__s != nullptr, "string_view::find(): received nullptr"); return __str_find (data(), size(), __s, __pos, traits_type::length(__s)); } // rfind _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type rfind(basic_string_view __s, size_type __pos = npos) const _NOEXCEPT { _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find(): received nullptr"); return __str_rfind (data(), size(), __s.data(), __pos, __s.size()); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type rfind(_CharT __c, size_type __pos = npos) const _NOEXCEPT { return __str_rfind (data(), size(), __c, __pos); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const { _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::rfind(): received nullptr"); return __str_rfind (data(), size(), __s, __pos, __n); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type rfind(const _CharT* __s, size_type __pos=npos) const { _LIBCPP_ASSERT(__s != nullptr, "string_view::rfind(): received nullptr"); return __str_rfind (data(), size(), __s, __pos, traits_type::length(__s)); } // find_first_of _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_of(basic_string_view __s, size_type __pos = 0) const _NOEXCEPT { _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_of(): received nullptr"); return __str_find_first_of (data(), size(), __s.data(), __pos, __s.size()); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_of(_CharT __c, size_type __pos = 0) const _NOEXCEPT { return find(__c, __pos); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_of(const _CharT* __s, size_type __pos, size_type __n) const { _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_of(): received nullptr"); return __str_find_first_of (data(), size(), __s, __pos, __n); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_of(const _CharT* __s, size_type __pos=0) const { _LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_of(): received nullptr"); return __str_find_first_of (data(), size(), __s, __pos, traits_type::length(__s)); } // find_last_of _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT { _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_of(): received nullptr"); return __str_find_last_of (data(), size(), __s.data(), __pos, __s.size()); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_of(_CharT __c, size_type __pos = npos) const _NOEXCEPT { return rfind(__c, __pos); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_of(const _CharT* __s, size_type __pos, size_type __n) const { _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_of(): received nullptr"); return __str_find_last_of (data(), size(), __s, __pos, __n); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_of(const _CharT* __s, size_type __pos=npos) const { _LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_of(): received nullptr"); return __str_find_last_of (data(), size(), __s, __pos, traits_type::length(__s)); } // find_first_not_of _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_not_of(basic_string_view __s, size_type __pos=0) const _NOEXCEPT { _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_first_not_of(): received nullptr"); return __str_find_first_not_of (data(), size(), __s.data(), __pos, __s.size()); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_not_of(_CharT __c, size_type __pos=0) const _NOEXCEPT { return __str_find_first_not_of (data(), size(), __c, __pos); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const { _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_first_not_of(): received nullptr"); return __str_find_first_not_of (data(), size(), __s, __pos, __n); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_first_not_of(const _CharT* __s, size_type __pos=0) const { _LIBCPP_ASSERT(__s != nullptr, "string_view::find_first_not_of(): received nullptr"); return __str_find_first_not_of (data(), size(), __s, __pos, traits_type::length(__s)); } // find_last_not_of _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_not_of(basic_string_view __s, size_type __pos=npos) const _NOEXCEPT { _LIBCPP_ASSERT(__s.size() == 0 || __s.data() != nullptr, "string_view::find_last_not_of(): received nullptr"); return __str_find_last_not_of (data(), size(), __s.data(), __pos, __s.size()); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_not_of(_CharT __c, size_type __pos=npos) const _NOEXCEPT { return __str_find_last_not_of (data(), size(), __c, __pos); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const { _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string_view::find_last_not_of(): received nullptr"); return __str_find_last_not_of (data(), size(), __s, __pos, __n); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY size_type find_last_not_of(const _CharT* __s, size_type __pos=npos) const { _LIBCPP_ASSERT(__s != nullptr, "string_view::find_last_not_of(): received nullptr"); return __str_find_last_not_of (data(), size(), __s, __pos, traits_type::length(__s)); } #if _LIBCPP_STD_VER > 17 _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool starts_with(basic_string_view __s) const _NOEXCEPT { return size() >= __s.size() && compare(0, __s.size(), __s) == 0; } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool starts_with(value_type __c) const _NOEXCEPT { return !empty() && _Traits::eq(front(), __c); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool starts_with(const value_type* __s) const _NOEXCEPT { return starts_with(basic_string_view(__s)); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool ends_with(basic_string_view __s) const _NOEXCEPT { return size() >= __s.size() && compare(size() - __s.size(), npos, __s) == 0; } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool ends_with(value_type __c) const _NOEXCEPT { return !empty() && _Traits::eq(back(), __c); } _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool ends_with(const value_type* __s) const _NOEXCEPT { return ends_with(basic_string_view(__s)); } #endif private: const value_type* __data; size_type __size; }; // [string.view.comparison] // operator == template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator==(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT { if ( __lhs.size() != __rhs.size()) return false; return __lhs.compare(__rhs) == 0; } template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator==(basic_string_view<_CharT, _Traits> __lhs, typename common_type >::type __rhs) _NOEXCEPT { if ( __lhs.size() != __rhs.size()) return false; return __lhs.compare(__rhs) == 0; } template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator==(typename common_type >::type __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT { if ( __lhs.size() != __rhs.size()) return false; return __lhs.compare(__rhs) == 0; } // operator != template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator!=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT { if ( __lhs.size() != __rhs.size()) return true; return __lhs.compare(__rhs) != 0; } template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator!=(basic_string_view<_CharT, _Traits> __lhs, typename common_type >::type __rhs) _NOEXCEPT { if ( __lhs.size() != __rhs.size()) return true; return __lhs.compare(__rhs) != 0; } template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator!=(typename common_type >::type __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT { if ( __lhs.size() != __rhs.size()) return true; return __lhs.compare(__rhs) != 0; } // operator < template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator<(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT { return __lhs.compare(__rhs) < 0; } template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator<(basic_string_view<_CharT, _Traits> __lhs, typename common_type >::type __rhs) _NOEXCEPT { return __lhs.compare(__rhs) < 0; } template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator<(typename common_type >::type __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT { return __lhs.compare(__rhs) < 0; } // operator > template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator> (basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT { return __lhs.compare(__rhs) > 0; } template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator>(basic_string_view<_CharT, _Traits> __lhs, typename common_type >::type __rhs) _NOEXCEPT { return __lhs.compare(__rhs) > 0; } template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator>(typename common_type >::type __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT { return __lhs.compare(__rhs) > 0; } // operator <= template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator<=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT { return __lhs.compare(__rhs) <= 0; } template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator<=(basic_string_view<_CharT, _Traits> __lhs, typename common_type >::type __rhs) _NOEXCEPT { return __lhs.compare(__rhs) <= 0; } template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator<=(typename common_type >::type __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT { return __lhs.compare(__rhs) <= 0; } // operator >= template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator>=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT { return __lhs.compare(__rhs) >= 0; } template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator>=(basic_string_view<_CharT, _Traits> __lhs, typename common_type >::type __rhs) _NOEXCEPT { return __lhs.compare(__rhs) >= 0; } template _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator>=(typename common_type >::type __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT { return __lhs.compare(__rhs) >= 0; } typedef basic_string_view string_view; typedef basic_string_view u16string_view; typedef basic_string_view u32string_view; typedef basic_string_view wstring_view; // [string.view.hash] template struct _LIBCPP_TEMPLATE_VIS hash > : public unary_function, size_t> { size_t operator()(const basic_string_view<_CharT, _Traits> __val) const _NOEXCEPT; }; template size_t hash >::operator()( const basic_string_view<_CharT, _Traits> __val) const _NOEXCEPT { return __do_string_hash(__val.data(), __val.data() + __val.size()); } #if _LIBCPP_STD_VER > 11 inline namespace literals { inline namespace string_view_literals { inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR basic_string_view operator "" sv(const char *__str, size_t __len) _NOEXCEPT { return basic_string_view (__str, __len); } inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR basic_string_view operator "" sv(const wchar_t *__str, size_t __len) _NOEXCEPT { return basic_string_view (__str, __len); } inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR basic_string_view operator "" sv(const char16_t *__str, size_t __len) _NOEXCEPT { return basic_string_view (__str, __len); } inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR basic_string_view operator "" sv(const char32_t *__str, size_t __len) _NOEXCEPT { return basic_string_view (__str, __len); } } } #endif _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS #endif // _LIBCPP_STRING_VIEW Index: projects/clang600-import/contrib/libc++ =================================================================== --- projects/clang600-import/contrib/libc++ (revision 327138) +++ projects/clang600-import/contrib/libc++ (revision 327139) Property changes on: projects/clang600-import/contrib/libc++ ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /vendor/libc++/dist:r327034-327138