aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2009-10-20 21:54:22 +0000
committerPaolo Carlini <paolo.carlini@oracle.com>2009-10-20 21:54:22 +0000
commitca363cde9f6cf07111fb7f9cc3e215739890f868 (patch)
treed9f0a70cd63a05ff0f5897ee3af169de24b15bd4
parent7df10e94fefbced3ce03b2d145289e377b6c17a1 (diff)
2009-10-20 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/41773 Revert: 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. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@153040 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--libstdc++-v3/ChangeLog23
-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, 69 insertions, 78 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 2140fdd7842..c13bb4005cc 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,26 @@
+009-10-20 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR libstdc++/41773
+ Revert:
+ 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-20 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/41763
diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver
index bad07588b82..2337a5a3fbf 100644
--- a/libstdc++-v3/config/abi/pre/gnu.ver
+++ b/libstdc++-v3/config/abi/pre/gnu.ver
@@ -1039,6 +1039,10 @@ 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 5ef6f007f40..9d44dc4fdfc 100644
--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -419,13 +419,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
/**
* @brief Default constructor creates an empty 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
- { }
+ inline
+ basic_string();
/**
* @brief Construct an empty string using allocator @a a.
@@ -1551,8 +1546,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__
@@ -1603,35 +1598,6 @@ _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*
@@ -1648,9 +1614,6 @@ _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:
/**
@@ -2216,6 +2179,15 @@ _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 1824eb7b6c0..d450a4717de 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 _FwdIterator>
+ template <typename _InIterator>
_CharT*
basic_string<_CharT, _Traits, _Alloc>::
- _S_construct(_FwdIterator __beg, _FwdIterator __end, const _Alloc& __a,
+ _S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a,
forward_iterator_tag)
{
#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
@@ -166,28 +166,6 @@ _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()),
@@ -207,7 +185,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
: _M_dataplus(_S_construct(__str._M_data()
+ __str._M_check(__pos,
"basic_string::basic_string"),
- __str._M_limit(__pos, __n), _Alloc()), _Alloc())
+ __str._M_data() + __str._M_limit(__pos, __n)
+ + __pos, _Alloc()), _Alloc())
{ }
template<typename _CharT, typename _Traits, typename _Alloc>
@@ -217,22 +196,23 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
: _M_dataplus(_S_construct(__str._M_data()
+ __str._M_check(__pos,
"basic_string::basic_string"),
- __str._M_limit(__pos, __n), __a), __a)
+ __str._M_data() + __str._M_limit(__pos, __n)
+ + __pos, __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, __n, __a), __a)
+ : _M_dataplus(_S_construct(__s, __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 ? traits_type::length(__s) : npos,
- __a), __a)
+ : _M_dataplus(_S_construct(__s, __s ? __s + traits_type::length(__s) :
+ __s + npos, __a), __a)
{ }
template<typename _CharT, typename _Traits, typename _Alloc>
@@ -244,17 +224,16 @@ _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.size(), __a), __a)
+ : _M_dataplus(_S_construct(__l.begin(), __l.end(), __a), __a)
{ }
#endif
diff --git a/libstdc++-v3/src/string-inst.cc b/libstdc++-v3/src/string-inst.cc
index eacebfb8e21..4ba178a5ad4 100644
--- a/libstdc++-v3/src/string-inst.cc
+++ b/libstdc++-v3/src/string-inst.cc
@@ -1,7 +1,6 @@
// Components for manipulating sequences of characters -*- C++ -*-
-// Copyright (C) 1997, 1998, 2009, 1999, 2000, 2001, 2002, 2003, 2004,
-// 2005, 2006, 2007, 2008, 2009
+// Copyright (C) 1997, 1998, 2009, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -59,6 +58,20 @@ _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)