Commit 1e736a95 by François Dumont

functions.h (__gnu_debug::__check_string): Move...

2018-07-06  François Dumont  <fdumont@gcc.gnu.org>

	* include/debug/functions.h (__gnu_debug::__check_string): Move...
	* include/debug/string (__gnu_debug::__check_string): ... here.
	(_GLIBCXX_DEBUG_VERIFY_STR_COND_AT): New.
	(__glibcxx_check_string_n_constructor): New.
	(__gnu_debug::basic_string<>(const _CharT*, size_type, const _Alloc&)):
	Use latter.
	(__glibcxx_check_string_constructor): New.
	(__gnu_debug::basic_string<>(const _CharT*, const _Alloc&)):
	Use latter.
	* testsuite/21_strings/basic_string/debug/1_neg.cc: New.
	* testsuite/21_strings/basic_string/debug/2_neg.cc: New.

From-SVN: r262480
parent 582d1f90
2018-07-06 François Dumont <fdumont@gcc.gnu.org>
* include/debug/functions.h (__gnu_debug::__check_string): Move...
* include/debug/string (__gnu_debug::__check_string): ... here.
(_GLIBCXX_DEBUG_VERIFY_STR_COND_AT): New.
(__glibcxx_check_string_n_constructor): New.
(__gnu_debug::basic_string<>(const _CharT*, size_type, const _Alloc&)):
Use latter.
(__glibcxx_check_string_constructor): New.
(__gnu_debug::basic_string<>(const _CharT*, const _Alloc&)):
Use latter.
* testsuite/21_strings/basic_string/debug/1_neg.cc: New.
* testsuite/21_strings/basic_string/debug/2_neg.cc: New.
2018-07-06 Jonathan Wakely <jwakely@redhat.com> 2018-07-06 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/84928 use std::move in <numeric> algorithms PR libstdc++/84928 use std::move in <numeric> algorithms
......
...@@ -211,29 +211,6 @@ namespace __gnu_debug ...@@ -211,29 +211,6 @@ namespace __gnu_debug
return __foreign_iterator_aux(__it, __other, __other_end, _Integral()); return __foreign_iterator_aux(__it, __other, __other_end, _Integral());
} }
/** Checks that __s is non-NULL or __n == 0, and then returns __s. */
template<typename _CharT, typename _Integer>
inline const _CharT*
__check_string(const _CharT* __s,
const _Integer& __n __attribute__((__unused__)))
{
#ifdef _GLIBCXX_DEBUG_PEDANTIC
__glibcxx_assert(__s != 0 || __n == 0);
#endif
return __s;
}
/** Checks that __s is non-NULL and then returns __s. */
template<typename _CharT>
inline const _CharT*
__check_string(const _CharT* __s)
{
#ifdef _GLIBCXX_DEBUG_PEDANTIC
__glibcxx_assert(__s != 0);
#endif
return __s;
}
// Can't check if an input iterator sequence is sorted, because we // Can't check if an input iterator sequence is sorted, because we
// can't step through the sequence. // can't step through the sequence.
template<typename _InputIterator> template<typename _InputIterator>
......
...@@ -36,701 +36,744 @@ ...@@ -36,701 +36,744 @@
#include <debug/safe_container.h> #include <debug/safe_container.h>
#include <debug/safe_iterator.h> #include <debug/safe_iterator.h>
#define _GLIBCXX_DEBUG_VERIFY_STR_COND_AT(_Cond,_File,_Line,_Func) \
if (! (_Cond)) \
__gnu_debug::_Error_formatter::_S_at(_File, _Line, _Func) \
._M_message(#_Cond)._M_error()
namespace __gnu_debug namespace __gnu_debug
{ {
/// Class std::basic_string with safety/checking/debug instrumentation. /** Checks that __s is non-NULL or __n == 0, and then returns __s. */
template<typename _CharT, typename _Traits = std::char_traits<_CharT>, template<typename _CharT, typename _Integer>
typename _Allocator = std::allocator<_CharT> > inline const _CharT*
class basic_string __check_string(const _CharT* __s,
: public __gnu_debug::_Safe_container< _Integer __n __attribute__((__unused__)),
basic_string<_CharT, _Traits, _Allocator>, const char* __file __attribute__((__unused__)),
_Allocator, _Safe_sequence, bool(_GLIBCXX_USE_CXX11_ABI)>, unsigned int __line __attribute__((__unused__)),
public std::basic_string<_CharT, _Traits, _Allocator> const char* __function __attribute__((__unused__)))
{ {
typedef std::basic_string<_CharT, _Traits, _Allocator> _Base; #ifdef _GLIBCXX_DEBUG_PEDANTIC
typedef __gnu_debug::_Safe_container< _GLIBCXX_DEBUG_VERIFY_STR_COND_AT(__s != 0 || __n == 0,
basic_string, _Allocator, _Safe_sequence, bool(_GLIBCXX_USE_CXX11_ABI)> __file, __line, __function);
#endif
return __s;
}
/** Checks that __s is non-NULL and then returns __s. */
template<typename _CharT>
inline const _CharT*
__check_string(const _CharT* __s,
const char* __file __attribute__((__unused__)),
unsigned int __line __attribute__((__unused__)),
const char* __function __attribute__((__unused__)))
{
#ifdef _GLIBCXX_DEBUG_PEDANTIC
_GLIBCXX_DEBUG_VERIFY_STR_COND_AT(__s != 0,
__file, __line, __function);
#endif
return __s;
}
#define __glibcxx_check_string_n_constructor(_Str, _Size) \
__check_string(_Str, _Size, __FILE__, __LINE__, __PRETTY_FUNCTION__)
#define __glibcxx_check_string_constructor(_Str) \
__check_string(_Str, __FILE__, __LINE__, __PRETTY_FUNCTION__)
/// Class std::basic_string with safety/checking/debug instrumentation.
template<typename _CharT, typename _Traits = std::char_traits<_CharT>,
typename _Allocator = std::allocator<_CharT> >
class basic_string
: public __gnu_debug::_Safe_container<
basic_string<_CharT, _Traits, _Allocator>,
_Allocator, _Safe_sequence, bool(_GLIBCXX_USE_CXX11_ABI)>,
public std::basic_string<_CharT, _Traits, _Allocator>
{
typedef std::basic_string<_CharT, _Traits, _Allocator> _Base;
typedef __gnu_debug::_Safe_container<
basic_string, _Allocator, _Safe_sequence, bool(_GLIBCXX_USE_CXX11_ABI)>
_Safe; _Safe;
public: public:
// types: // types:
typedef _Traits traits_type; typedef _Traits traits_type;
typedef typename _Traits::char_type value_type; typedef typename _Traits::char_type value_type;
typedef _Allocator allocator_type; typedef _Allocator allocator_type;
typedef typename _Base::size_type size_type; typedef typename _Base::size_type size_type;
typedef typename _Base::difference_type difference_type; typedef typename _Base::difference_type difference_type;
typedef typename _Base::reference reference; typedef typename _Base::reference reference;
typedef typename _Base::const_reference const_reference; typedef typename _Base::const_reference const_reference;
typedef typename _Base::pointer pointer; typedef typename _Base::pointer pointer;
typedef typename _Base::const_pointer const_pointer; typedef typename _Base::const_pointer const_pointer;
typedef __gnu_debug::_Safe_iterator< typedef __gnu_debug::_Safe_iterator<
typename _Base::iterator, basic_string> iterator; typename _Base::iterator, basic_string> iterator;
typedef __gnu_debug::_Safe_iterator< typedef __gnu_debug::_Safe_iterator<
typename _Base::const_iterator, basic_string> const_iterator; typename _Base::const_iterator, basic_string> const_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator; typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator; typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
using _Base::npos; using _Base::npos;
basic_string() basic_string()
_GLIBCXX_NOEXCEPT_IF(std::is_nothrow_default_constructible<_Base>::value) _GLIBCXX_NOEXCEPT_IF(std::is_nothrow_default_constructible<_Base>::value)
: _Base() { } : _Base() { }
// 21.3.1 construct/copy/destroy: // 21.3.1 construct/copy/destroy:
explicit explicit
basic_string(const _Allocator& __a) _GLIBCXX_NOEXCEPT basic_string(const _Allocator& __a) _GLIBCXX_NOEXCEPT
: _Base(__a) { } : _Base(__a) { }
#if __cplusplus < 201103L #if __cplusplus < 201103L
basic_string(const basic_string& __str) basic_string(const basic_string& __str)
: _Base(__str) { } : _Base(__str) { }
~basic_string() { } ~basic_string() { }
#else #else
basic_string(const basic_string&) = default; basic_string(const basic_string&) = default;
basic_string(basic_string&&) = default; basic_string(basic_string&&) = default;
basic_string(std::initializer_list<_CharT> __l, basic_string(std::initializer_list<_CharT> __l,
const _Allocator& __a = _Allocator()) const _Allocator& __a = _Allocator())
: _Base(__l, __a) : _Base(__l, __a)
{ } { }
#if _GLIBCXX_USE_CXX11_ABI #if _GLIBCXX_USE_CXX11_ABI
basic_string(const basic_string& __s, const _Allocator& __a) basic_string(const basic_string& __s, const _Allocator& __a)
: _Base(__s, __a) { } : _Base(__s, __a) { }
basic_string(basic_string&& __s, const _Allocator& __a) basic_string(basic_string&& __s, const _Allocator& __a)
: _Base(std::move(__s), __a) { } : _Base(std::move(__s), __a) { }
#endif #endif
~basic_string() = default; ~basic_string() = default;
// Provides conversion from a normal-mode string to a debug-mode string // Provides conversion from a normal-mode string to a debug-mode string
basic_string(_Base&& __base) noexcept basic_string(_Base&& __base) noexcept
: _Base(std::move(__base)) { } : _Base(std::move(__base)) { }
#endif // C++11 #endif // C++11
// Provides conversion from a normal-mode string to a debug-mode string // Provides conversion from a normal-mode string to a debug-mode string
basic_string(const _Base& __base) basic_string(const _Base& __base)
: _Base(__base) { } : _Base(__base) { }
// _GLIBCXX_RESOLVE_LIB_DEFECTS // _GLIBCXX_RESOLVE_LIB_DEFECTS
// 42. string ctors specify wrong default allocator // 42. string ctors specify wrong default allocator
basic_string(const basic_string& __str, size_type __pos, basic_string(const basic_string& __str, size_type __pos,
size_type __n = _Base::npos, size_type __n = _Base::npos,
const _Allocator& __a = _Allocator()) const _Allocator& __a = _Allocator())
: _Base(__str, __pos, __n, __a) { } : _Base(__str, __pos, __n, __a) { }
basic_string(const _CharT* __s, size_type __n, basic_string(const _CharT* __s, size_type __n,
const _Allocator& __a = _Allocator()) const _Allocator& __a = _Allocator())
: _Base(__gnu_debug::__check_string(__s, __n), __n, __a) { } : _Base(__glibcxx_check_string_n_constructor(__s, __n), __n, __a) { }
basic_string(const _CharT* __s, const _Allocator& __a = _Allocator()) basic_string(const _CharT* __s, const _Allocator& __a = _Allocator())
: _Base(__gnu_debug::__check_string(__s), __a) : _Base(__glibcxx_check_string_constructor(__s), __a)
{ this->assign(__s); } { this->assign(__s); }
basic_string(size_type __n, _CharT __c, basic_string(size_type __n, _CharT __c,
const _Allocator& __a = _Allocator()) const _Allocator& __a = _Allocator())
: _Base(__n, __c, __a) { } : _Base(__n, __c, __a) { }
template<typename _InputIterator> template<typename _InputIterator>
basic_string(_InputIterator __begin, _InputIterator __end, basic_string(_InputIterator __begin, _InputIterator __end,
const _Allocator& __a = _Allocator()) const _Allocator& __a = _Allocator())
: _Base(__gnu_debug::__base( : _Base(__gnu_debug::__base(
__glibcxx_check_valid_constructor_range(__begin, __end)), __glibcxx_check_valid_constructor_range(__begin, __end)),
__gnu_debug::__base(__end), __a) { } __gnu_debug::__base(__end), __a) { }
#if __cplusplus < 201103L #if __cplusplus < 201103L
basic_string& basic_string&
operator=(const basic_string& __str) operator=(const basic_string& __str)
{ {
this->_M_safe() = __str; this->_M_safe() = __str;
_M_base() = __str; _M_base() = __str;
return *this; return *this;
} }
#else #else
basic_string& basic_string&
operator=(const basic_string&) = default; operator=(const basic_string&) = default;
basic_string& basic_string&
operator=(basic_string&&) = default; operator=(basic_string&&) = default;
#endif #endif
basic_string& basic_string&
operator=(const _CharT* __s) operator=(const _CharT* __s)
{ {
__glibcxx_check_string(__s); __glibcxx_check_string(__s);
_M_base() = __s; _M_base() = __s;
this->_M_invalidate_all(); this->_M_invalidate_all();
return *this; return *this;
} }
basic_string& basic_string&
operator=(_CharT __c) operator=(_CharT __c)
{ {
_M_base() = __c; _M_base() = __c;
this->_M_invalidate_all(); this->_M_invalidate_all();
return *this; return *this;
} }
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
basic_string& basic_string&
operator=(std::initializer_list<_CharT> __l) operator=(std::initializer_list<_CharT> __l)
{ {
_M_base() = __l; _M_base() = __l;
this->_M_invalidate_all(); this->_M_invalidate_all();
return *this; return *this;
} }
#endif // C++11 #endif // C++11
// 21.3.2 iterators: // 21.3.2 iterators:
iterator iterator
begin() // _GLIBCXX_NOEXCEPT begin() // _GLIBCXX_NOEXCEPT
{ return iterator(_Base::begin(), this); } { return iterator(_Base::begin(), this); }
const_iterator const_iterator
begin() const _GLIBCXX_NOEXCEPT begin() const _GLIBCXX_NOEXCEPT
{ return const_iterator(_Base::begin(), this); } { return const_iterator(_Base::begin(), this); }
iterator iterator
end() // _GLIBCXX_NOEXCEPT end() // _GLIBCXX_NOEXCEPT
{ return iterator(_Base::end(), this); } { return iterator(_Base::end(), this); }
const_iterator const_iterator
end() const _GLIBCXX_NOEXCEPT end() const _GLIBCXX_NOEXCEPT
{ return const_iterator(_Base::end(), this); } { return const_iterator(_Base::end(), this); }
reverse_iterator reverse_iterator
rbegin() // _GLIBCXX_NOEXCEPT rbegin() // _GLIBCXX_NOEXCEPT
{ return reverse_iterator(end()); } { return reverse_iterator(end()); }
const_reverse_iterator const_reverse_iterator
rbegin() const _GLIBCXX_NOEXCEPT rbegin() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(end()); } { return const_reverse_iterator(end()); }
reverse_iterator reverse_iterator
rend() // _GLIBCXX_NOEXCEPT rend() // _GLIBCXX_NOEXCEPT
{ return reverse_iterator(begin()); } { return reverse_iterator(begin()); }
const_reverse_iterator const_reverse_iterator
rend() const _GLIBCXX_NOEXCEPT rend() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(begin()); } { return const_reverse_iterator(begin()); }
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
const_iterator const_iterator
cbegin() const noexcept cbegin() const noexcept
{ return const_iterator(_Base::begin(), this); } { return const_iterator(_Base::begin(), this); }
const_iterator const_iterator
cend() const noexcept cend() const noexcept
{ return const_iterator(_Base::end(), this); } { return const_iterator(_Base::end(), this); }
const_reverse_iterator const_reverse_iterator
crbegin() const noexcept crbegin() const noexcept
{ return const_reverse_iterator(end()); } { return const_reverse_iterator(end()); }
const_reverse_iterator const_reverse_iterator
crend() const noexcept crend() const noexcept
{ return const_reverse_iterator(begin()); } { return const_reverse_iterator(begin()); }
#endif #endif
// 21.3.3 capacity: // 21.3.3 capacity:
using _Base::size; using _Base::size;
using _Base::length; using _Base::length;
using _Base::max_size; using _Base::max_size;
void void
resize(size_type __n, _CharT __c) resize(size_type __n, _CharT __c)
{ {
_Base::resize(__n, __c); _Base::resize(__n, __c);
this->_M_invalidate_all(); this->_M_invalidate_all();
} }
void void
resize(size_type __n) resize(size_type __n)
{ this->resize(__n, _CharT()); } { this->resize(__n, _CharT()); }
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
void void
shrink_to_fit() noexcept shrink_to_fit() noexcept
{ {
if (capacity() > size()) if (capacity() > size())
{ {
__try __try
{ {
reserve(0); reserve(0);
this->_M_invalidate_all(); this->_M_invalidate_all();
} }
__catch(...) __catch(...)
{ } { }
} }
} }
#endif #endif
using _Base::capacity; using _Base::capacity;
using _Base::reserve; using _Base::reserve;
void void
clear() // _GLIBCXX_NOEXCEPT clear() // _GLIBCXX_NOEXCEPT
{ {
_Base::clear(); _Base::clear();
this->_M_invalidate_all(); this->_M_invalidate_all();
} }
using _Base::empty; using _Base::empty;
// 21.3.4 element access: // 21.3.4 element access:
const_reference const_reference
operator[](size_type __pos) const _GLIBCXX_NOEXCEPT operator[](size_type __pos) const _GLIBCXX_NOEXCEPT
{ {
_GLIBCXX_DEBUG_VERIFY(__pos <= this->size(), _GLIBCXX_DEBUG_VERIFY(__pos <= this->size(),
_M_message(__gnu_debug::__msg_subscript_oob) _M_message(__gnu_debug::__msg_subscript_oob)
._M_sequence(*this, "this") ._M_sequence(*this, "this")
._M_integer(__pos, "__pos") ._M_integer(__pos, "__pos")
._M_integer(this->size(), "size")); ._M_integer(this->size(), "size"));
return _M_base()[__pos]; return _M_base()[__pos];
} }
reference reference
operator[](size_type __pos) // _GLIBCXX_NOEXCEPT operator[](size_type __pos) // _GLIBCXX_NOEXCEPT
{ {
#if __cplusplus < 201103L && defined(_GLIBCXX_DEBUG_PEDANTIC) #if __cplusplus < 201103L && defined(_GLIBCXX_DEBUG_PEDANTIC)
__glibcxx_check_subscript(__pos); __glibcxx_check_subscript(__pos);
#else #else
// as an extension v3 allows s[s.size()] when s is non-const. // as an extension v3 allows s[s.size()] when s is non-const.
_GLIBCXX_DEBUG_VERIFY(__pos <= this->size(), _GLIBCXX_DEBUG_VERIFY(__pos <= this->size(),
_M_message(__gnu_debug::__msg_subscript_oob) _M_message(__gnu_debug::__msg_subscript_oob)
._M_sequence(*this, "this") ._M_sequence(*this, "this")
._M_integer(__pos, "__pos") ._M_integer(__pos, "__pos")
._M_integer(this->size(), "size")); ._M_integer(this->size(), "size"));
#endif #endif
return _M_base()[__pos]; return _M_base()[__pos];
} }
using _Base::at; using _Base::at;
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
using _Base::front; using _Base::front;
using _Base::back; using _Base::back;
#endif #endif
// 21.3.5 modifiers: // 21.3.5 modifiers:
basic_string& basic_string&
operator+=(const basic_string& __str) operator+=(const basic_string& __str)
{ {
_M_base() += __str; _M_base() += __str;
this->_M_invalidate_all(); this->_M_invalidate_all();
return *this; return *this;
} }
basic_string& basic_string&
operator+=(const _CharT* __s) operator+=(const _CharT* __s)
{ {
__glibcxx_check_string(__s); __glibcxx_check_string(__s);
_M_base() += __s; _M_base() += __s;
this->_M_invalidate_all(); this->_M_invalidate_all();
return *this; return *this;
} }
basic_string& basic_string&
operator+=(_CharT __c) operator+=(_CharT __c)
{ {
_M_base() += __c; _M_base() += __c;
this->_M_invalidate_all(); this->_M_invalidate_all();
return *this; return *this;
} }
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
basic_string& basic_string&
operator+=(std::initializer_list<_CharT> __l) operator+=(std::initializer_list<_CharT> __l)
{ {
_M_base() += __l; _M_base() += __l;
this->_M_invalidate_all(); this->_M_invalidate_all();
return *this; return *this;
} }
#endif // C++11 #endif // C++11
basic_string& basic_string&
append(const basic_string& __str) append(const basic_string& __str)
{ {
_Base::append(__str); _Base::append(__str);
this->_M_invalidate_all(); this->_M_invalidate_all();
return *this; return *this;
} }
basic_string&
append(const basic_string& __str, size_type __pos, size_type __n)
{
_Base::append(__str, __pos, __n);
this->_M_invalidate_all();
return *this;
}
basic_string&
append(const _CharT* __s, size_type __n)
{
__glibcxx_check_string_len(__s, __n);
_Base::append(__s, __n);
this->_M_invalidate_all();
return *this;
}
basic_string&
append(const _CharT* __s)
{
__glibcxx_check_string(__s);
_Base::append(__s);
this->_M_invalidate_all();
return *this;
}
basic_string& basic_string&
append(size_type __n, _CharT __c) append(const basic_string& __str, size_type __pos, size_type __n)
{ {
_Base::append(__n, __c); _Base::append(__str, __pos, __n);
this->_M_invalidate_all(); this->_M_invalidate_all();
return *this; return *this;
} }
template<typename _InputIterator>
basic_string& basic_string&
append(_InputIterator __first, _InputIterator __last) append(const _CharT* __s, size_type __n)
{ {
typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist; __glibcxx_check_string_len(__s, __n);
__glibcxx_check_valid_range2(__first, __last, __dist); _Base::append(__s, __n);
this->_M_invalidate_all();
return *this;
}
if (__dist.second >= __dp_sign) basic_string&
_Base::append(__gnu_debug::__unsafe(__first), append(const _CharT* __s)
__gnu_debug::__unsafe(__last)); {
else __glibcxx_check_string(__s);
_Base::append(__first, __last); _Base::append(__s);
this->_M_invalidate_all();
return *this;
}
basic_string&
append(size_type __n, _CharT __c)
{
_Base::append(__n, __c);
this->_M_invalidate_all(); this->_M_invalidate_all();
return *this; return *this;
} }
// _GLIBCXX_RESOLVE_LIB_DEFECTS template<typename _InputIterator>
// 7. string clause minor problems basic_string&
void append(_InputIterator __first, _InputIterator __last)
push_back(_CharT __c) {
{ typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
_Base::push_back(__c); __glibcxx_check_valid_range2(__first, __last, __dist);
this->_M_invalidate_all();
}
basic_string& if (__dist.second >= __dp_sign)
assign(const basic_string& __x) _Base::append(__gnu_debug::__unsafe(__first),
{ __gnu_debug::__unsafe(__last));
_Base::assign(__x); else
this->_M_invalidate_all(); _Base::append(__first, __last);
return *this;
}
#if __cplusplus >= 201103L this->_M_invalidate_all();
basic_string& return *this;
assign(basic_string&& __x) }
noexcept(noexcept(std::declval<_Base&>().assign(std::move(__x))))
{
_Base::assign(std::move(__x));
this->_M_invalidate_all();
return *this;
}
#endif // C++11
basic_string& // _GLIBCXX_RESOLVE_LIB_DEFECTS
assign(const basic_string& __str, size_type __pos, size_type __n) // 7. string clause minor problems
{ void
_Base::assign(__str, __pos, __n); push_back(_CharT __c)
this->_M_invalidate_all(); {
return *this; _Base::push_back(__c);
} this->_M_invalidate_all();
}
basic_string& basic_string&
assign(const _CharT* __s, size_type __n) assign(const basic_string& __x)
{ {
__glibcxx_check_string_len(__s, __n); _Base::assign(__x);
_Base::assign(__s, __n); this->_M_invalidate_all();
this->_M_invalidate_all(); return *this;
return *this; }
}
basic_string& #if __cplusplus >= 201103L
assign(const _CharT* __s) basic_string&
{ assign(basic_string&& __x)
__glibcxx_check_string(__s); noexcept(noexcept(std::declval<_Base&>().assign(std::move(__x))))
_Base::assign(__s); {
this->_M_invalidate_all(); _Base::assign(std::move(__x));
return *this; this->_M_invalidate_all();
} return *this;
}
#endif // C++11
basic_string& basic_string&
assign(size_type __n, _CharT __c) assign(const basic_string& __str, size_type __pos, size_type __n)
{ {
_Base::assign(__n, __c); _Base::assign(__str, __pos, __n);
this->_M_invalidate_all(); this->_M_invalidate_all();
return *this; return *this;
} }
template<typename _InputIterator>
basic_string& basic_string&
assign(_InputIterator __first, _InputIterator __last) assign(const _CharT* __s, size_type __n)
{ {
typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist; __glibcxx_check_string_len(__s, __n);
__glibcxx_check_valid_range2(__first, __last, __dist); _Base::assign(__s, __n);
this->_M_invalidate_all();
return *this;
}
if (__dist.second >= __dp_sign) basic_string&
_Base::assign(__gnu_debug::__unsafe(__first), assign(const _CharT* __s)
__gnu_debug::__unsafe(__last)); {
else __glibcxx_check_string(__s);
_Base::assign(__first, __last); _Base::assign(__s);
this->_M_invalidate_all();
return *this;
}
basic_string&
assign(size_type __n, _CharT __c)
{
_Base::assign(__n, __c);
this->_M_invalidate_all(); this->_M_invalidate_all();
return *this; return *this;
} }
#if __cplusplus >= 201103L template<typename _InputIterator>
basic_string& basic_string&
assign(std::initializer_list<_CharT> __l) assign(_InputIterator __first, _InputIterator __last)
{ {
_Base::assign(__l); typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
this->_M_invalidate_all(); __glibcxx_check_valid_range2(__first, __last, __dist);
return *this;
}
#endif // C++11
basic_string& if (__dist.second >= __dp_sign)
insert(size_type __pos1, const basic_string& __str) _Base::assign(__gnu_debug::__unsafe(__first),
{ __gnu_debug::__unsafe(__last));
_Base::insert(__pos1, __str); else
this->_M_invalidate_all(); _Base::assign(__first, __last);
return *this;
}
basic_string& this->_M_invalidate_all();
insert(size_type __pos1, const basic_string& __str, return *this;
size_type __pos2, size_type __n) }
{
_Base::insert(__pos1, __str, __pos2, __n);
this->_M_invalidate_all();
return *this;
}
basic_string& #if __cplusplus >= 201103L
insert(size_type __pos, const _CharT* __s, size_type __n) basic_string&
{ assign(std::initializer_list<_CharT> __l)
__glibcxx_check_string(__s); {
_Base::insert(__pos, __s, __n); _Base::assign(__l);
this->_M_invalidate_all(); this->_M_invalidate_all();
return *this; return *this;
} }
#endif // C++11
basic_string& basic_string&
insert(size_type __pos, const _CharT* __s) insert(size_type __pos1, const basic_string& __str)
{ {
__glibcxx_check_string(__s); _Base::insert(__pos1, __str);
_Base::insert(__pos, __s); this->_M_invalidate_all();
this->_M_invalidate_all(); return *this;
return *this; }
}
basic_string& basic_string&
insert(size_type __pos, size_type __n, _CharT __c) insert(size_type __pos1, const basic_string& __str,
{ size_type __pos2, size_type __n)
_Base::insert(__pos, __n, __c); {
this->_M_invalidate_all(); _Base::insert(__pos1, __str, __pos2, __n);
return *this; this->_M_invalidate_all();
} return *this;
}
iterator basic_string&
insert(const_iterator __p, _CharT __c) insert(size_type __pos, const _CharT* __s, size_type __n)
{ {
__glibcxx_check_insert(__p); __glibcxx_check_string(__s);
typename _Base::iterator __res = _Base::insert(__p.base(), __c); _Base::insert(__pos, __s, __n);
this->_M_invalidate_all(); this->_M_invalidate_all();
return iterator(__res, this); return *this;
} }
iterator basic_string&
insert(const_iterator __p, size_type __n, _CharT __c) insert(size_type __pos, const _CharT* __s)
{ {
__glibcxx_check_insert(__p); __glibcxx_check_string(__s);
typename _Base::iterator __res = _Base::insert(__p.base(), __n, __c); _Base::insert(__pos, __s);
this->_M_invalidate_all(); this->_M_invalidate_all();
return iterator(__res, this); return *this;
} }
basic_string&
insert(size_type __pos, size_type __n, _CharT __c)
{
_Base::insert(__pos, __n, __c);
this->_M_invalidate_all();
return *this;
}
template<typename _InputIterator>
iterator iterator
insert(const_iterator __p, _InputIterator __first, _InputIterator __last) insert(const_iterator __p, _CharT __c)
{ {
typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist; __glibcxx_check_insert(__p);
__glibcxx_check_insert_range(__p, __first, __last, __dist); typename _Base::iterator __res = _Base::insert(__p.base(), __c);
this->_M_invalidate_all();
return iterator(__res, this);
}
typename _Base::iterator __res; iterator
if (__dist.second >= __dp_sign) insert(const_iterator __p, size_type __n, _CharT __c)
__res = _Base::insert(__p.base(), __gnu_debug::__unsafe(__first), {
__gnu_debug::__unsafe(__last)); __glibcxx_check_insert(__p);
else typename _Base::iterator __res = _Base::insert(__p.base(), __n, __c);
__res = _Base::insert(__p.base(), __first, __last);
this->_M_invalidate_all(); this->_M_invalidate_all();
return iterator(__res, this); return iterator(__res, this);
} }
template<typename _InputIterator>
iterator
insert(const_iterator __p,
_InputIterator __first, _InputIterator __last)
{
typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
__glibcxx_check_insert_range(__p, __first, __last, __dist);
typename _Base::iterator __res;
if (__dist.second >= __dp_sign)
__res = _Base::insert(__p.base(), __gnu_debug::__unsafe(__first),
__gnu_debug::__unsafe(__last));
else
__res = _Base::insert(__p.base(), __first, __last);
this->_M_invalidate_all();
return iterator(__res, this);
}
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
iterator iterator
insert(const_iterator __p, std::initializer_list<_CharT> __l) insert(const_iterator __p, std::initializer_list<_CharT> __l)
{ {
__glibcxx_check_insert(__p); __glibcxx_check_insert(__p);
const auto __res = _Base::insert(__p.base(), __l); const auto __res = _Base::insert(__p.base(), __l);
this->_M_invalidate_all(); this->_M_invalidate_all();
return iterator(__res, this); return iterator(__res, this);
} }
#endif // C++11 #endif // C++11
basic_string& basic_string&
erase(size_type __pos = 0, size_type __n = _Base::npos) erase(size_type __pos = 0, size_type __n = _Base::npos)
{ {
_Base::erase(__pos, __n); _Base::erase(__pos, __n);
this->_M_invalidate_all(); this->_M_invalidate_all();
return *this; return *this;
} }
iterator iterator
erase(iterator __position) erase(iterator __position)
{ {
__glibcxx_check_erase(__position); __glibcxx_check_erase(__position);
typename _Base::iterator __res = _Base::erase(__position.base()); typename _Base::iterator __res = _Base::erase(__position.base());
this->_M_invalidate_all(); this->_M_invalidate_all();
return iterator(__res, this); return iterator(__res, this);
} }
iterator iterator
erase(iterator __first, iterator __last) erase(iterator __first, iterator __last)
{ {
// _GLIBCXX_RESOLVE_LIB_DEFECTS // _GLIBCXX_RESOLVE_LIB_DEFECTS
// 151. can't currently clear() empty container // 151. can't currently clear() empty container
__glibcxx_check_erase_range(__first, __last); __glibcxx_check_erase_range(__first, __last);
typename _Base::iterator __res = _Base::erase(__first.base(), typename _Base::iterator __res = _Base::erase(__first.base(),
__last.base()); __last.base());
this->_M_invalidate_all(); this->_M_invalidate_all();
return iterator(__res, this); return iterator(__res, this);
} }
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
void void
pop_back() // noexcept pop_back() // noexcept
{ {
__glibcxx_check_nonempty(); __glibcxx_check_nonempty();
_Base::pop_back(); _Base::pop_back();
this->_M_invalidate_all(); this->_M_invalidate_all();
} }
#endif // C++11 #endif // C++11
basic_string& basic_string&
replace(size_type __pos1, size_type __n1, const basic_string& __str) replace(size_type __pos1, size_type __n1, const basic_string& __str)
{ {
_Base::replace(__pos1, __n1, __str); _Base::replace(__pos1, __n1, __str);
this->_M_invalidate_all(); this->_M_invalidate_all();
return *this; return *this;
} }
basic_string&
replace(size_type __pos1, size_type __n1, const basic_string& __str,
size_type __pos2, size_type __n2)
{
_Base::replace(__pos1, __n1, __str, __pos2, __n2);
this->_M_invalidate_all();
return *this;
}
basic_string&
replace(size_type __pos, size_type __n1, const _CharT* __s,
size_type __n2)
{
__glibcxx_check_string_len(__s, __n2);
_Base::replace(__pos, __n1, __s, __n2);
this->_M_invalidate_all();
return *this;
}
basic_string&
replace(size_type __pos, size_type __n1, const _CharT* __s)
{
__glibcxx_check_string(__s);
_Base::replace(__pos, __n1, __s);
this->_M_invalidate_all();
return *this;
}
basic_string&
replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
{
_Base::replace(__pos, __n1, __n2, __c);
this->_M_invalidate_all();
return *this;
}
basic_string& basic_string&
replace(iterator __i1, iterator __i2, const basic_string& __str) replace(size_type __pos1, size_type __n1, const basic_string& __str,
{ size_type __pos2, size_type __n2)
__glibcxx_check_erase_range(__i1, __i2); {
_Base::replace(__i1.base(), __i2.base(), __str); _Base::replace(__pos1, __n1, __str, __pos2, __n2);
this->_M_invalidate_all(); this->_M_invalidate_all();
return *this; return *this;
} }
basic_string& basic_string&
replace(iterator __i1, iterator __i2, const _CharT* __s, size_type __n) replace(size_type __pos, size_type __n1, const _CharT* __s,
{ size_type __n2)
__glibcxx_check_erase_range(__i1, __i2); {
__glibcxx_check_string_len(__s, __n); __glibcxx_check_string_len(__s, __n2);
_Base::replace(__i1.base(), __i2.base(), __s, __n); _Base::replace(__pos, __n1, __s, __n2);
this->_M_invalidate_all(); this->_M_invalidate_all();
return *this; return *this;
} }
basic_string& basic_string&
replace(iterator __i1, iterator __i2, const _CharT* __s) replace(size_type __pos, size_type __n1, const _CharT* __s)
{ {
__glibcxx_check_erase_range(__i1, __i2); __glibcxx_check_string(__s);
__glibcxx_check_string(__s); _Base::replace(__pos, __n1, __s);
_Base::replace(__i1.base(), __i2.base(), __s); this->_M_invalidate_all();
this->_M_invalidate_all(); return *this;
return *this; }
}
basic_string& basic_string&
replace(iterator __i1, iterator __i2, size_type __n, _CharT __c) replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
{ {
__glibcxx_check_erase_range(__i1, __i2); _Base::replace(__pos, __n1, __n2, __c);
_Base::replace(__i1.base(), __i2.base(), __n, __c); this->_M_invalidate_all();
this->_M_invalidate_all(); return *this;
return *this; }
}
template<typename _InputIterator>
basic_string& basic_string&
replace(iterator __i1, iterator __i2, replace(iterator __i1, iterator __i2, const basic_string& __str)
_InputIterator __j1, _InputIterator __j2)
{ {
__glibcxx_check_erase_range(__i1, __i2); __glibcxx_check_erase_range(__i1, __i2);
_Base::replace(__i1.base(), __i2.base(), __str);
this->_M_invalidate_all();
return *this;
}
typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist; basic_string&
__glibcxx_check_valid_range2(__j1, __j2, __dist); replace(iterator __i1, iterator __i2, const _CharT* __s, size_type __n)
{
__glibcxx_check_erase_range(__i1, __i2);
__glibcxx_check_string_len(__s, __n);
_Base::replace(__i1.base(), __i2.base(), __s, __n);
this->_M_invalidate_all();
return *this;
}
if (__dist.second >= __dp_sign) basic_string&
_Base::replace(__i1.base(), __i2.base(), replace(iterator __i1, iterator __i2, const _CharT* __s)
__gnu_debug::__unsafe(__j1), {
__gnu_debug::__unsafe(__j2)); __glibcxx_check_erase_range(__i1, __i2);
else __glibcxx_check_string(__s);
_Base::replace(__i1.base(), __i2.base(), __j1, __j2); _Base::replace(__i1.base(), __i2.base(), __s);
this->_M_invalidate_all();
return *this;
}
basic_string&
replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
{
__glibcxx_check_erase_range(__i1, __i2);
_Base::replace(__i1.base(), __i2.base(), __n, __c);
this->_M_invalidate_all(); this->_M_invalidate_all();
return *this; return *this;
} }
template<typename _InputIterator>
basic_string&
replace(iterator __i1, iterator __i2,
_InputIterator __j1, _InputIterator __j2)
{
__glibcxx_check_erase_range(__i1, __i2);
typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
__glibcxx_check_valid_range2(__j1, __j2, __dist);
if (__dist.second >= __dp_sign)
_Base::replace(__i1.base(), __i2.base(),
__gnu_debug::__unsafe(__j1),
__gnu_debug::__unsafe(__j2));
else
_Base::replace(__i1.base(), __i2.base(), __j1, __j2);
this->_M_invalidate_all();
return *this;
}
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
basic_string& replace(iterator __i1, iterator __i2, basic_string& replace(iterator __i1, iterator __i2,
std::initializer_list<_CharT> __l) std::initializer_list<_CharT> __l)
...@@ -742,233 +785,233 @@ template<typename _CharT, typename _Traits = std::char_traits<_CharT>, ...@@ -742,233 +785,233 @@ template<typename _CharT, typename _Traits = std::char_traits<_CharT>,
} }
#endif // C++11 #endif // C++11
size_type size_type
copy(_CharT* __s, size_type __n, size_type __pos = 0) const copy(_CharT* __s, size_type __n, size_type __pos = 0) const
{ {
__glibcxx_check_string_len(__s, __n); __glibcxx_check_string_len(__s, __n);
return _Base::copy(__s, __n, __pos); return _Base::copy(__s, __n, __pos);
} }
void void
swap(basic_string& __x) swap(basic_string& __x)
_GLIBCXX_NOEXCEPT_IF(std::__is_nothrow_swappable<_Base>::value) _GLIBCXX_NOEXCEPT_IF(std::__is_nothrow_swappable<_Base>::value)
{ {
_Safe::_M_swap(__x); _Safe::_M_swap(__x);
_Base::swap(__x); _Base::swap(__x);
} }
// 21.3.6 string operations: // 21.3.6 string operations:
const _CharT* const _CharT*
c_str() const _GLIBCXX_NOEXCEPT c_str() const _GLIBCXX_NOEXCEPT
{ {
const _CharT* __res = _Base::c_str(); const _CharT* __res = _Base::c_str();
this->_M_invalidate_all(); this->_M_invalidate_all();
return __res; return __res;
} }
const _CharT* const _CharT*
data() const _GLIBCXX_NOEXCEPT data() const _GLIBCXX_NOEXCEPT
{ {
const _CharT* __res = _Base::data(); const _CharT* __res = _Base::data();
this->_M_invalidate_all(); this->_M_invalidate_all();
return __res; return __res;
} }
using _Base::get_allocator; using _Base::get_allocator;
size_type size_type
find(const basic_string& __str, size_type __pos = 0) const find(const basic_string& __str, size_type __pos = 0) const
_GLIBCXX_NOEXCEPT _GLIBCXX_NOEXCEPT
{ return _Base::find(__str, __pos); } { return _Base::find(__str, __pos); }
size_type size_type
find(const _CharT* __s, size_type __pos, size_type __n) const find(const _CharT* __s, size_type __pos, size_type __n) const
{ {
__glibcxx_check_string(__s); __glibcxx_check_string(__s);
return _Base::find(__s, __pos, __n); return _Base::find(__s, __pos, __n);
} }
size_type size_type
find(const _CharT* __s, size_type __pos = 0) const find(const _CharT* __s, size_type __pos = 0) const
{ {
__glibcxx_check_string(__s); __glibcxx_check_string(__s);
return _Base::find(__s, __pos); return _Base::find(__s, __pos);
} }
size_type size_type
find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
{ return _Base::find(__c, __pos); } { return _Base::find(__c, __pos); }
size_type size_type
rfind(const basic_string& __str, size_type __pos = _Base::npos) const rfind(const basic_string& __str, size_type __pos = _Base::npos) const
_GLIBCXX_NOEXCEPT _GLIBCXX_NOEXCEPT
{ return _Base::rfind(__str, __pos); } { return _Base::rfind(__str, __pos); }
size_type size_type
rfind(const _CharT* __s, size_type __pos, size_type __n) const rfind(const _CharT* __s, size_type __pos, size_type __n) const
{ {
__glibcxx_check_string_len(__s, __n); __glibcxx_check_string_len(__s, __n);
return _Base::rfind(__s, __pos, __n); return _Base::rfind(__s, __pos, __n);
} }
size_type size_type
rfind(const _CharT* __s, size_type __pos = _Base::npos) const rfind(const _CharT* __s, size_type __pos = _Base::npos) const
{ {
__glibcxx_check_string(__s); __glibcxx_check_string(__s);
return _Base::rfind(__s, __pos); return _Base::rfind(__s, __pos);
} }
size_type size_type
rfind(_CharT __c, size_type __pos = _Base::npos) const _GLIBCXX_NOEXCEPT rfind(_CharT __c, size_type __pos = _Base::npos) const _GLIBCXX_NOEXCEPT
{ return _Base::rfind(__c, __pos); } { return _Base::rfind(__c, __pos); }
size_type size_type
find_first_of(const basic_string& __str, size_type __pos = 0) const find_first_of(const basic_string& __str, size_type __pos = 0) const
_GLIBCXX_NOEXCEPT _GLIBCXX_NOEXCEPT
{ return _Base::find_first_of(__str, __pos); } { return _Base::find_first_of(__str, __pos); }
size_type size_type
find_first_of(const _CharT* __s, size_type __pos, size_type __n) const find_first_of(const _CharT* __s, size_type __pos, size_type __n) const
{ {
__glibcxx_check_string(__s); __glibcxx_check_string(__s);
return _Base::find_first_of(__s, __pos, __n); return _Base::find_first_of(__s, __pos, __n);
} }
size_type size_type
find_first_of(const _CharT* __s, size_type __pos = 0) const find_first_of(const _CharT* __s, size_type __pos = 0) const
{ {
__glibcxx_check_string(__s); __glibcxx_check_string(__s);
return _Base::find_first_of(__s, __pos); return _Base::find_first_of(__s, __pos);
} }
size_type size_type
find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
{ return _Base::find_first_of(__c, __pos); } { return _Base::find_first_of(__c, __pos); }
size_type size_type
find_last_of(const basic_string& __str, find_last_of(const basic_string& __str,
size_type __pos = _Base::npos) const _GLIBCXX_NOEXCEPT size_type __pos = _Base::npos) const _GLIBCXX_NOEXCEPT
{ return _Base::find_last_of(__str, __pos); } { return _Base::find_last_of(__str, __pos); }
size_type size_type
find_last_of(const _CharT* __s, size_type __pos, size_type __n) const find_last_of(const _CharT* __s, size_type __pos, size_type __n) const
{ {
__glibcxx_check_string(__s); __glibcxx_check_string(__s);
return _Base::find_last_of(__s, __pos, __n); return _Base::find_last_of(__s, __pos, __n);
} }
size_type size_type
find_last_of(const _CharT* __s, size_type __pos = _Base::npos) const find_last_of(const _CharT* __s, size_type __pos = _Base::npos) const
{ {
__glibcxx_check_string(__s); __glibcxx_check_string(__s);
return _Base::find_last_of(__s, __pos); return _Base::find_last_of(__s, __pos);
} }
size_type size_type
find_last_of(_CharT __c, size_type __pos = _Base::npos) const find_last_of(_CharT __c, size_type __pos = _Base::npos) const
_GLIBCXX_NOEXCEPT _GLIBCXX_NOEXCEPT
{ return _Base::find_last_of(__c, __pos); } { return _Base::find_last_of(__c, __pos); }
size_type size_type
find_first_not_of(const basic_string& __str, size_type __pos = 0) const find_first_not_of(const basic_string& __str, size_type __pos = 0) const
_GLIBCXX_NOEXCEPT _GLIBCXX_NOEXCEPT
{ return _Base::find_first_not_of(__str, __pos); } { return _Base::find_first_not_of(__str, __pos); }
size_type size_type
find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const
{ {
__glibcxx_check_string_len(__s, __n); __glibcxx_check_string_len(__s, __n);
return _Base::find_first_not_of(__s, __pos, __n); return _Base::find_first_not_of(__s, __pos, __n);
} }
size_type size_type
find_first_not_of(const _CharT* __s, size_type __pos = 0) const find_first_not_of(const _CharT* __s, size_type __pos = 0) const
{ {
__glibcxx_check_string(__s); __glibcxx_check_string(__s);
return _Base::find_first_not_of(__s, __pos); return _Base::find_first_not_of(__s, __pos);
} }
size_type size_type
find_first_not_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT find_first_not_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
{ return _Base::find_first_not_of(__c, __pos); } { return _Base::find_first_not_of(__c, __pos); }
size_type size_type
find_last_not_of(const basic_string& __str, find_last_not_of(const basic_string& __str,
size_type __pos = _Base::npos) const size_type __pos = _Base::npos) const
_GLIBCXX_NOEXCEPT _GLIBCXX_NOEXCEPT
{ return _Base::find_last_not_of(__str, __pos); } { return _Base::find_last_not_of(__str, __pos); }
size_type size_type
find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const
{ {
__glibcxx_check_string(__s); __glibcxx_check_string(__s);
return _Base::find_last_not_of(__s, __pos, __n); return _Base::find_last_not_of(__s, __pos, __n);
} }
size_type size_type
find_last_not_of(const _CharT* __s, size_type __pos = _Base::npos) const find_last_not_of(const _CharT* __s, size_type __pos = _Base::npos) const
{ {
__glibcxx_check_string(__s); __glibcxx_check_string(__s);
return _Base::find_last_not_of(__s, __pos); return _Base::find_last_not_of(__s, __pos);
} }
size_type size_type
find_last_not_of(_CharT __c, size_type __pos = _Base::npos) const find_last_not_of(_CharT __c, size_type __pos = _Base::npos) const
_GLIBCXX_NOEXCEPT _GLIBCXX_NOEXCEPT
{ return _Base::find_last_not_of(__c, __pos); } { return _Base::find_last_not_of(__c, __pos); }
basic_string basic_string
substr(size_type __pos = 0, size_type __n = _Base::npos) const substr(size_type __pos = 0, size_type __n = _Base::npos) const
{ return basic_string(_Base::substr(__pos, __n)); } { return basic_string(_Base::substr(__pos, __n)); }
int int
compare(const basic_string& __str) const compare(const basic_string& __str) const
{ return _Base::compare(__str); } { return _Base::compare(__str); }
int int
compare(size_type __pos1, size_type __n1, compare(size_type __pos1, size_type __n1,
const basic_string& __str) const const basic_string& __str) const
{ return _Base::compare(__pos1, __n1, __str); } { return _Base::compare(__pos1, __n1, __str); }
int int
compare(size_type __pos1, size_type __n1, const basic_string& __str, compare(size_type __pos1, size_type __n1, const basic_string& __str,
size_type __pos2, size_type __n2) const size_type __pos2, size_type __n2) const
{ return _Base::compare(__pos1, __n1, __str, __pos2, __n2); } { return _Base::compare(__pos1, __n1, __str, __pos2, __n2); }
int int
compare(const _CharT* __s) const compare(const _CharT* __s) const
{ {
__glibcxx_check_string(__s); __glibcxx_check_string(__s);
return _Base::compare(__s); return _Base::compare(__s);
} }
// _GLIBCXX_RESOLVE_LIB_DEFECTS // _GLIBCXX_RESOLVE_LIB_DEFECTS
// 5. string::compare specification questionable // 5. string::compare specification questionable
int int
compare(size_type __pos1, size_type __n1, const _CharT* __s) const compare(size_type __pos1, size_type __n1, const _CharT* __s) const
{ {
__glibcxx_check_string(__s); __glibcxx_check_string(__s);
return _Base::compare(__pos1, __n1, __s); return _Base::compare(__pos1, __n1, __s);
} }
// _GLIBCXX_RESOLVE_LIB_DEFECTS // _GLIBCXX_RESOLVE_LIB_DEFECTS
// 5. string::compare specification questionable // 5. string::compare specification questionable
int int
compare(size_type __pos1, size_type __n1,const _CharT* __s, compare(size_type __pos1, size_type __n1,const _CharT* __s,
size_type __n2) const size_type __n2) const
{ {
__glibcxx_check_string_len(__s, __n2); __glibcxx_check_string_len(__s, __n2);
return _Base::compare(__pos1, __n1, __s, __n2); return _Base::compare(__pos1, __n1, __s, __n2);
} }
_Base& _Base&
_M_base() _GLIBCXX_NOEXCEPT { return *this; } _M_base() _GLIBCXX_NOEXCEPT { return *this; }
const _Base& const _Base&
_M_base() const _GLIBCXX_NOEXCEPT { return *this; } _M_base() const _GLIBCXX_NOEXCEPT { return *this; }
using _Safe::_M_invalidate_all; using _Safe::_M_invalidate_all;
}; };
template<typename _CharT, typename _Traits, typename _Allocator> template<typename _CharT, typename _Traits, typename _Allocator>
inline basic_string<_CharT,_Traits,_Allocator> inline basic_string<_CharT,_Traits,_Allocator>
......
// Copyright (C) 2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
//
// { dg-do run { xfail *-*-* } }
#define _GLIBCXX_DEBUG_PEDANTIC
#include <debug/string>
void test01()
{
const char* __null_str = 0;
__gnu_debug::string str(__null_str, 1);
}
int main()
{
test01();
return 0;
}
// Copyright (C) 2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
//
// { dg-do run { xfail *-*-* } }
#define _GLIBCXX_DEBUG_PEDANTIC
#include <debug/string>
void test01()
{
const char* __null_str = 0;
__gnu_debug::string str(__null_str);
}
int main()
{
test01();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment