2
0
mirror of git://gcc.gnu.org/git/gcc.git synced 2025-04-18 01:20:48 +08:00

sso_string_base.h (struct __sso_string_local): Remove...

2005-10-05  Paolo Carlini  <pcarlini@suse.de>

	* include/ext/sso_string_base.h (struct __sso_string_local):
	Remove, actually POD types cannot have user defined constructors
	(being aggregates) and therefore can always be members of unions.
	(class __sso_string_base): Adjust consistently.

From-SVN: r105021
This commit is contained in:
Paolo Carlini 2005-10-05 23:50:18 +00:00 committed by Paolo Carlini
parent d14e25e00b
commit c54c1b2b52
2 changed files with 30 additions and 53 deletions
libstdc++-v3

@ -1,3 +1,10 @@
2005-10-05 Paolo Carlini <pcarlini@suse.de>
* include/ext/sso_string_base.h (struct __sso_string_local):
Remove, actually POD types cannot have user defined constructors
(being aggregates) and therefore can always be members of unions.
(class __sso_string_base): Adjust consistently.
2005-10-05 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/24198

@ -38,44 +38,10 @@
namespace __gnu_cxx
{
// N.B. According to 3.9/10 and 9/4, POD types can have user-defined
// constructors: in that case, cannot be member of an union (9.5/1).
// See, f.i., class gnu_char_type in the testsuite.
template<typename _CharT, typename _Traits, typename _Alloc,
bool = std::__is_scalar<_CharT>::__value>
struct __sso_string_local
{
typedef typename __vstring_utility<_CharT, _Traits, _Alloc>::
_CharT_alloc_type::size_type size_type;
enum { _S_local_capacity = 15 };
union
{
_CharT _M_local_data[_S_local_capacity + 1];
size_type _M_allocated_capacity;
};
};
template<typename _CharT, typename _Traits, typename _Alloc>
struct __sso_string_local<_CharT, _Traits, _Alloc, false>
{
typedef typename __vstring_utility<_CharT, _Traits, _Alloc>::
_CharT_alloc_type::size_type size_type;
enum { _S_local_capacity = 15 };
_CharT _M_local_data[_S_local_capacity + 1];
size_type _M_allocated_capacity;
};
template<typename _CharT, typename _Traits, typename _Alloc>
class __sso_string_base
: protected __vstring_utility<_CharT, _Traits, _Alloc>,
private __sso_string_local<_CharT, _Traits, _Alloc>
: protected __vstring_utility<_CharT, _Traits, _Alloc>
{
typedef __sso_string_local<_CharT, _Traits, _Alloc> _Local;
public:
typedef _Traits traits_type;
typedef typename _Traits::char_type value_type;
@ -100,25 +66,7 @@ namespace __gnu_cxx
private:
static const _CharT _S_terminal;
using _Local::_S_local_capacity;
using _Local::_M_local_data;
using _Local::_M_allocated_capacity;
// Create & Destroy
_CharT*
_M_create(size_type&, size_type);
void
_M_dispose() throw()
{
if (!_M_is_local())
_M_destroy(_M_allocated_capacity + 1);
}
void
_M_destroy(size_type) throw();
// Use empty-base optimization: http://www.cantrip.org/emptyopt.html
struct _Alloc_hider : _Alloc
{
@ -132,6 +80,14 @@ namespace __gnu_cxx
_Alloc_hider _M_dataplus;
size_type _M_string_length;
enum { _S_local_capacity = 15 };
union
{
_CharT _M_local_data[_S_local_capacity + 1];
size_type _M_allocated_capacity;
};
_CharT*
_M_data(_CharT* __p)
{ return (_M_dataplus._M_p = __p); }
@ -148,6 +104,20 @@ namespace __gnu_cxx
_M_is_local() const
{ return _M_data() == _M_local_data; }
// Create & Destroy
_CharT*
_M_create(size_type&, size_type);
void
_M_dispose() throw()
{
if (!_M_is_local())
_M_destroy(_M_allocated_capacity + 1);
}
void
_M_destroy(size_type) throw();
// _M_construct_aux is used to implement the 21.3.1 para 15 which
// requires special behaviour if _InIter is an integral type
template<class _InIterator>