aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2009-10-20 16:24:18 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2009-10-20 16:24:18 +0000
commit50e9ed7c6c75bae523aa32887b8f91b06070901d (patch)
treeb99a859bfc08400bc5dd8f0b4f2793ab1dd171d4
parent1578e91079162f7ff008520487623968fc0db687 (diff)
downloadgcc-50e9ed7c6c75bae523aa32887b8f91b06070901d.zip
gcc-50e9ed7c6c75bae523aa32887b8f91b06070901d.tar.gz
gcc-50e9ed7c6c75bae523aa32887b8f91b06070901d.tar.bz2
basic_string.h (_S_construct(const _CharT*, size_type, const _Alloc&)): New, declare.
2009-10-20 Paolo Carlini <paolo.carlini@oracle.com> * include/bits/basic_string.h (_S_construct(const _CharT*, size_type, const _Alloc&)): New, declare. (_S_construct(_CharT*, _CharT*, const _Alloc&), _S_construct(const _CharT*, const _CharT*, const _Alloc&), _S_construct(iterator, iterator, const _Alloc&), _S_construct(const_iterator, const_iterator, const _Alloc&)): New, forward to the latter. * include/bits/basic_string.tcc (_S_construct(const _CharT*, size_type, const _Alloc&)): Define. (basic_string(const basic_string&, size_type, size_type), basic_string(const basic_string&, size_type, size_type, const _Alloc&), basic_string(const _CharT*, size_type, const _Alloc&), basic_string(const _CharT*, const _Alloc&), basic_string(initializer_list<>, const _Alloc&)): Call the latter. * config/abi/pre/gnu.ver: Remove recently added exports. * src/string-inst.cc: Remove instantiations. From-SVN: r153023
-rw-r--r--libstdc++-v3/ChangeLog19
-rw-r--r--libstdc++-v3/config/abi/pre/gnu.ver4
-rw-r--r--libstdc++-v3/include/bits/basic_string.h54
-rw-r--r--libstdc++-v3/include/bits/basic_string.tcc49
-rw-r--r--libstdc++-v3/src/string-inst.cc17
5 files changed, 97 insertions, 46 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 3f1ea98..d23a3ce 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,22 @@
+2009-10-20 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * include/bits/basic_string.h (_S_construct(const _CharT*, size_type,
+ const _Alloc&)): New, declare.
+ (_S_construct(_CharT*, _CharT*, const _Alloc&),
+ _S_construct(const _CharT*, const _CharT*, const _Alloc&),
+ _S_construct(iterator, iterator, const _Alloc&),
+ _S_construct(const_iterator, const_iterator, const _Alloc&)): New,
+ forward to the latter.
+ * include/bits/basic_string.tcc (_S_construct(const _CharT*,
+ size_type, const _Alloc&)): Define.
+ (basic_string(const basic_string&, size_type, size_type),
+ basic_string(const basic_string&, size_type, size_type,
+ const _Alloc&), basic_string(const _CharT*, size_type,
+ const _Alloc&), basic_string(const _CharT*, const _Alloc&),
+ basic_string(initializer_list<>, const _Alloc&)): Call the latter.
+ * config/abi/pre/gnu.ver: Remove recently added exports.
+ * src/string-inst.cc: Remove instantiations.
+
2009-10-15 Phil Muldoon <pmuldoon@redhat.com>
* python/libstdcxx/v6/printers.py (StdTuplePrinter): New printer.
diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver
index 2337a5a..bad0758 100644
--- a/libstdc++-v3/config/abi/pre/gnu.ver
+++ b/libstdc++-v3/config/abi/pre/gnu.ver
@@ -1039,10 +1039,6 @@ GLIBCXX_3.4.14 {
_ZNKSbIwSt11char_traitsIwESaIwEE7crbeginEv;
_ZNKSbIwSt11char_traitsIwESaIwEE5crendEv;
- # string|wstring ::_S_construct<> helpers
- _ZNSs12_S_constructI*;
- _ZNSbIwSt11char_traitsIwESaIwEE12_S_constructI*;
-
} GLIBCXX_3.4.13;
# Symbols in the support library (libsupc++) have their own tag.
diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h
index 9d44dc4..5ef6f00 100644
--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -419,8 +419,13 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
/**
* @brief Default constructor creates an empty string.
*/
- inline
- basic_string();
+ basic_string()
+#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
+ : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc())
+#else
+ : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc())
+#endif
+ { }
/**
* @brief Construct an empty string using allocator @a a.
@@ -1546,8 +1551,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
* max_size(), length_error is thrown. The value of the string doesn't
* change if an error is thrown.
*/
- basic_string& replace(iterator __i1, iterator __i2,
- initializer_list<_CharT> __l)
+ basic_string&
+ replace(iterator __i1, iterator __i2, initializer_list<_CharT> __l)
{ return this->replace(__i1, __i2, __l.begin(), __l.end()); }
#endif // __GXX_EXPERIMENTAL_CXX0X__
@@ -1598,6 +1603,35 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
return _S_construct_aux(__beg, __end, __a, _Integral());
}
+ static _CharT*
+ _S_construct(_CharT* __beg, _CharT* __end, const _Alloc& __a)
+ {
+ __glibcxx_requires_valid_range(__beg, __end);
+ return _S_construct(__beg, __end - __beg, __a);
+ }
+
+ static _CharT*
+ _S_construct(const _CharT* __beg, const _CharT* __end, const _Alloc& __a)
+ {
+ __glibcxx_requires_valid_range(__beg, __end);
+ return _S_construct(__beg, __end - __beg, __a);
+ }
+
+ static _CharT*
+ _S_construct(iterator __beg, iterator __end, const _Alloc& __a)
+ {
+ __glibcxx_requires_valid_range(__beg, __end);
+ return _S_construct(__beg.base(), __end - __beg, __a);
+ }
+
+ static _CharT*
+ _S_construct(const_iterator __beg, const_iterator __end,
+ const _Alloc& __a)
+ {
+ __glibcxx_requires_valid_range(__beg, __end);
+ return _S_construct(__beg.base(), __end - __beg, __a);
+ }
+
// For Input Iterators, used in istreambuf_iterators, etc.
template<class _InIterator>
static _CharT*
@@ -1614,6 +1648,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
static _CharT*
_S_construct(size_type __req, _CharT __c, const _Alloc& __a);
+ static _CharT*
+ _S_construct(const _CharT* __s, size_type __n, const _Alloc& __a);
+
public:
/**
@@ -2179,15 +2216,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
size_type __n2) const;
};
- template<typename _CharT, typename _Traits, typename _Alloc>
- inline basic_string<_CharT, _Traits, _Alloc>::
- basic_string()
-#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
- : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc()) { }
-#else
- : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc()) { }
-#endif
-
// operator+
/**
* @brief Concatenate two strings.
diff --git a/libstdc++-v3/include/bits/basic_string.tcc b/libstdc++-v3/include/bits/basic_string.tcc
index d450a47..1824eb7 100644
--- a/libstdc++-v3/include/bits/basic_string.tcc
+++ b/libstdc++-v3/include/bits/basic_string.tcc
@@ -118,10 +118,10 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
}
template<typename _CharT, typename _Traits, typename _Alloc>
- template <typename _InIterator>
+ template <typename _FwdIterator>
_CharT*
basic_string<_CharT, _Traits, _Alloc>::
- _S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a,
+ _S_construct(_FwdIterator __beg, _FwdIterator __end, const _Alloc& __a,
forward_iterator_tag)
{
#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
@@ -166,6 +166,28 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
}
template<typename _CharT, typename _Traits, typename _Alloc>
+ _CharT*
+ basic_string<_CharT, _Traits, _Alloc>::
+ _S_construct(const _CharT* __s, size_type __n, const _Alloc& __a)
+ {
+#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
+ if (__n == 0 && __a == _Alloc())
+ return _S_empty_rep()._M_refdata();
+#endif
+ // NB: Not required, but considered best practice.
+ if (__gnu_cxx::__is_null_pointer(__s) && __n)
+ __throw_logic_error(__N("basic_string::_S_construct NULL not valid"));
+
+ // Check for out_of_range and length_error exceptions.
+ _Rep* __r = _Rep::_S_create(__n, size_type(0), __a);
+ if (__n)
+ _M_copy(__r->_M_refdata(), __s, __n);
+
+ __r->_M_set_length_and_sharable(__n);
+ return __r->_M_refdata();
+ }
+
+ template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>::
basic_string(const basic_string& __str)
: _M_dataplus(__str._M_rep()->_M_grab(_Alloc(__str.get_allocator()),
@@ -185,8 +207,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
: _M_dataplus(_S_construct(__str._M_data()
+ __str._M_check(__pos,
"basic_string::basic_string"),
- __str._M_data() + __str._M_limit(__pos, __n)
- + __pos, _Alloc()), _Alloc())
+ __str._M_limit(__pos, __n), _Alloc()), _Alloc())
{ }
template<typename _CharT, typename _Traits, typename _Alloc>
@@ -196,23 +217,22 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
: _M_dataplus(_S_construct(__str._M_data()
+ __str._M_check(__pos,
"basic_string::basic_string"),
- __str._M_data() + __str._M_limit(__pos, __n)
- + __pos, __a), __a)
+ __str._M_limit(__pos, __n), __a), __a)
{ }
// TBD: DPG annotate
template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>::
basic_string(const _CharT* __s, size_type __n, const _Alloc& __a)
- : _M_dataplus(_S_construct(__s, __s + __n, __a), __a)
+ : _M_dataplus(_S_construct(__s, __n, __a), __a)
{ }
// TBD: DPG annotate
template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>::
basic_string(const _CharT* __s, const _Alloc& __a)
- : _M_dataplus(_S_construct(__s, __s ? __s + traits_type::length(__s) :
- __s + npos, __a), __a)
+ : _M_dataplus(_S_construct(__s, __s ? traits_type::length(__s) : npos,
+ __a), __a)
{ }
template<typename _CharT, typename _Traits, typename _Alloc>
@@ -224,16 +244,17 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
// TBD: DPG annotate
template<typename _CharT, typename _Traits, typename _Alloc>
template<typename _InputIterator>
- basic_string<_CharT, _Traits, _Alloc>::
- basic_string(_InputIterator __beg, _InputIterator __end, const _Alloc& __a)
- : _M_dataplus(_S_construct(__beg, __end, __a), __a)
- { }
+ basic_string<_CharT, _Traits, _Alloc>::
+ basic_string(_InputIterator __beg, _InputIterator __end,
+ const _Alloc& __a)
+ : _M_dataplus(_S_construct(__beg, __end, __a), __a)
+ { }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>::
basic_string(initializer_list<_CharT> __l, const _Alloc& __a)
- : _M_dataplus(_S_construct(__l.begin(), __l.end(), __a), __a)
+ : _M_dataplus(_S_construct(__l.begin(), __l.size(), __a), __a)
{ }
#endif
diff --git a/libstdc++-v3/src/string-inst.cc b/libstdc++-v3/src/string-inst.cc
index 4ba178a..eacebfb 100644
--- a/libstdc++-v3/src/string-inst.cc
+++ b/libstdc++-v3/src/string-inst.cc
@@ -1,6 +1,7 @@
// Components for manipulating sequences of characters -*- C++ -*-
-// Copyright (C) 1997, 1998, 2009, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+// Copyright (C) 1997, 1998, 2009, 1999, 2000, 2001, 2002, 2003, 2004,
+// 2005, 2006, 2007, 2008, 2009
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -58,20 +59,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
template
S::basic_string(S::iterator, S::iterator, const allocator<C>&);
- template
- C*
- S::_S_construct(S::iterator, S::iterator,
- const allocator<C>&, forward_iterator_tag);
-
- template
- C*
- S::_S_construct(C*, C*, const allocator<C>&, forward_iterator_tag);
-
- template
- C*
- S::_S_construct(const C*, const C*, const allocator<C>&,
- forward_iterator_tag);
-
_GLIBCXX_END_NAMESPACE
_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)