mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-02-23 04:19:09 +08:00
stl_algobase.h (__copy_aux(_II, _II, _OI), [...]): Use __is_pod.
2007-04-03 Paolo Carlini <pcarlini@suse.de> * include/bits/stl_algobase.h (__copy_aux(_II, _II, _OI), __copy_backward_aux(_BI1, _BI1, _BI2)): Use __is_pod. * include/bits/stl_deque.h (deque<>::_M_destroy_data(iterator, iterator, const std::allocator<>&)): Use __has_trivial_constructor. (deque<>::_M_destroy_data_dispatch): Remove. * include/bits/stl_uninitialized.h (uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator), uninitialized_fill(_ForwardIterator, _ForwardIterator, const _Tp&), uninitialized_fill_n(_ForwardIterator, _Size, const _Tp&)): Use __is_pod. * include/bits/stl_tempbuf.h (_Temporary_buffer:: _Temporary_buffer(_ForwardIterator, _ForwardIterator)): Use __is_pod. (_Temporary_buffer::_M_initialize_buffer): Remove. * include/bits/stl_construct.h (_Destroy(_ForwardIterator, _ForwardIterator)): Use __has_trivial_destructor. (__destroy_aux): Remove. From-SVN: r123480
This commit is contained in:
parent
e1584860ef
commit
ff2ea58742
@ -1,3 +1,21 @@
|
||||
2007-04-03 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
* include/bits/stl_algobase.h (__copy_aux(_II, _II, _OI),
|
||||
__copy_backward_aux(_BI1, _BI1, _BI2)): Use __is_pod.
|
||||
* include/bits/stl_deque.h (deque<>::_M_destroy_data(iterator,
|
||||
iterator, const std::allocator<>&)): Use __has_trivial_constructor.
|
||||
(deque<>::_M_destroy_data_dispatch): Remove.
|
||||
* include/bits/stl_uninitialized.h (uninitialized_copy(_InputIterator,
|
||||
_InputIterator, _ForwardIterator), uninitialized_fill(_ForwardIterator,
|
||||
_ForwardIterator, const _Tp&), uninitialized_fill_n(_ForwardIterator,
|
||||
_Size, const _Tp&)): Use __is_pod.
|
||||
* include/bits/stl_tempbuf.h (_Temporary_buffer::
|
||||
_Temporary_buffer(_ForwardIterator, _ForwardIterator)): Use __is_pod.
|
||||
(_Temporary_buffer::_M_initialize_buffer): Remove.
|
||||
* include/bits/stl_construct.h (_Destroy(_ForwardIterator,
|
||||
_ForwardIterator)): Use __has_trivial_destructor.
|
||||
(__destroy_aux): Remove.
|
||||
|
||||
2007-04-03 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
* include/bits/stl_map.h (map<>::insert(iterator, const value_type&):
|
||||
|
@ -341,7 +341,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
||||
typedef typename iterator_traits<_II>::value_type _ValueTypeI;
|
||||
typedef typename iterator_traits<_OI>::value_type _ValueTypeO;
|
||||
typedef typename iterator_traits<_II>::iterator_category _Category;
|
||||
const bool __simple = (__is_scalar<_ValueTypeI>::__value
|
||||
const bool __simple = (__is_pod(_ValueTypeI)
|
||||
&& __is_pointer<_II>::__value
|
||||
&& __is_pointer<_OI>::__value
|
||||
&& __are_same<_ValueTypeI, _ValueTypeO>::__value);
|
||||
@ -495,7 +495,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
||||
typedef typename iterator_traits<_BI1>::value_type _ValueType1;
|
||||
typedef typename iterator_traits<_BI2>::value_type _ValueType2;
|
||||
typedef typename iterator_traits<_BI1>::iterator_category _Category;
|
||||
const bool __simple = (__is_scalar<_ValueType1>::__value
|
||||
const bool __simple = (__is_pod(_ValueType1)
|
||||
&& __is_pointer<_BI1>::__value
|
||||
&& __is_pointer<_BI2>::__value
|
||||
&& __are_same<_ValueType1, _ValueType2>::__value);
|
||||
|
@ -1,6 +1,7 @@
|
||||
// nonstandard construct and destroy functions -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
|
||||
// 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
|
||||
@ -61,7 +62,6 @@
|
||||
#ifndef _STL_CONSTRUCT_H
|
||||
#define _STL_CONSTRUCT_H 1
|
||||
|
||||
#include <bits/cpp_type_traits.h>
|
||||
#include <new>
|
||||
|
||||
_GLIBCXX_BEGIN_NAMESPACE(std)
|
||||
@ -106,36 +106,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
||||
_Destroy(_Tp* __pointer)
|
||||
{ __pointer->~_Tp(); }
|
||||
|
||||
/**
|
||||
* @if maint
|
||||
* Destroy a range of objects with nontrivial destructors.
|
||||
*
|
||||
* This is a helper function used only by _Destroy().
|
||||
* @endif
|
||||
*/
|
||||
template<typename _ForwardIterator>
|
||||
inline void
|
||||
__destroy_aux(_ForwardIterator __first, _ForwardIterator __last,
|
||||
__false_type)
|
||||
{
|
||||
for (; __first != __last; ++__first)
|
||||
std::_Destroy(&*__first);
|
||||
}
|
||||
|
||||
/**
|
||||
* @if maint
|
||||
* Destroy a range of objects with trivial destructors. Since the destructors
|
||||
* are trivial, there's nothing to do and hopefully this function will be
|
||||
* entirely optimized away.
|
||||
*
|
||||
* This is a helper function used only by _Destroy().
|
||||
* @endif
|
||||
*/
|
||||
template<typename _ForwardIterator>
|
||||
inline void
|
||||
__destroy_aux(_ForwardIterator, _ForwardIterator, __true_type)
|
||||
{ }
|
||||
|
||||
/**
|
||||
* @if maint
|
||||
* Destroy a range of objects. If the value_type of the object has
|
||||
@ -149,10 +119,9 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
||||
{
|
||||
typedef typename iterator_traits<_ForwardIterator>::value_type
|
||||
_Value_type;
|
||||
typedef typename std::__is_scalar<_Value_type>::__type
|
||||
_Has_trivial_destructor;
|
||||
|
||||
std::__destroy_aux(__first, __last, _Has_trivial_destructor());
|
||||
if (!__has_trivial_destructor(_Value_type))
|
||||
for (; __first != __last; ++__first)
|
||||
std::_Destroy(&*__first);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Deque implementation -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006
|
||||
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
|
||||
// Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
@ -1424,13 +1424,6 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD)
|
||||
void
|
||||
_M_destroy_data_aux(iterator __first, iterator __last);
|
||||
|
||||
void
|
||||
_M_destroy_data_dispatch(iterator, iterator, __true_type) { }
|
||||
|
||||
void
|
||||
_M_destroy_data_dispatch(iterator __first, iterator __last, __false_type)
|
||||
{ _M_destroy_data_aux(__first, __last); }
|
||||
|
||||
// Called by ~deque().
|
||||
// NB: Doesn't deallocate the nodes.
|
||||
template<typename _Alloc1>
|
||||
@ -1442,9 +1435,8 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD)
|
||||
_M_destroy_data(iterator __first, iterator __last,
|
||||
const std::allocator<_Tp>&)
|
||||
{
|
||||
typedef typename std::__is_scalar<value_type>::__type
|
||||
_Has_trivial_destructor;
|
||||
_M_destroy_data_dispatch(__first, __last, _Has_trivial_destructor());
|
||||
if (!__has_trivial_destructor(value_type))
|
||||
_M_destroy_data_aux(__first, __last);
|
||||
}
|
||||
|
||||
// Called by erase(q1, q2).
|
||||
|
@ -90,13 +90,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
||||
size_type _M_len;
|
||||
pointer _M_buffer;
|
||||
|
||||
void
|
||||
_M_initialize_buffer(const _Tp&, __true_type) { }
|
||||
|
||||
void
|
||||
_M_initialize_buffer(const _Tp& __val, __false_type)
|
||||
{ std::uninitialized_fill_n(_M_buffer, _M_len, __val); }
|
||||
|
||||
public:
|
||||
/// As per Table mumble.
|
||||
size_type
|
||||
@ -145,17 +138,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
||||
: _M_original_len(std::distance(__first, __last)),
|
||||
_M_len(0), _M_buffer(0)
|
||||
{
|
||||
// Workaround for a __type_traits bug in the pre-7.3 compiler.
|
||||
typedef typename std::__is_scalar<_Tp>::__type _Trivial;
|
||||
|
||||
try
|
||||
{
|
||||
pair<pointer, size_type> __p(get_temporary_buffer<
|
||||
value_type>(_M_original_len));
|
||||
_M_buffer = __p.first;
|
||||
_M_len = __p.second;
|
||||
if (_M_len > 0)
|
||||
_M_initialize_buffer(*__first, _Trivial());
|
||||
if (!__is_pod(_Tp) && _M_len > 0)
|
||||
std::uninitialized_fill_n(_M_buffer, _M_len, *__first);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
|
@ -64,19 +64,11 @@
|
||||
|
||||
_GLIBCXX_BEGIN_NAMESPACE(std)
|
||||
|
||||
// uninitialized_copy
|
||||
template<typename _InputIterator, typename _ForwardIterator>
|
||||
inline _ForwardIterator
|
||||
__uninitialized_copy_aux(_InputIterator __first, _InputIterator __last,
|
||||
_ForwardIterator __result,
|
||||
__true_type)
|
||||
{ return std::copy(__first, __last, __result); }
|
||||
|
||||
template<typename _InputIterator, typename _ForwardIterator>
|
||||
inline _ForwardIterator
|
||||
__uninitialized_copy_aux(_InputIterator __first, _InputIterator __last,
|
||||
_ForwardIterator __result,
|
||||
__false_type)
|
||||
_ForwardIterator
|
||||
__uninitialized_copy_aux(_InputIterator __first,
|
||||
_InputIterator __last,
|
||||
_ForwardIterator __result)
|
||||
{
|
||||
_ForwardIterator __cur = __result;
|
||||
try
|
||||
@ -106,25 +98,20 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
||||
uninitialized_copy(_InputIterator __first, _InputIterator __last,
|
||||
_ForwardIterator __result)
|
||||
{
|
||||
typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType;
|
||||
typedef typename std::__is_scalar<_ValueType>::__type _Is_POD;
|
||||
return std::__uninitialized_copy_aux(__first, __last, __result,
|
||||
_Is_POD());
|
||||
typedef typename iterator_traits<_ForwardIterator>::value_type
|
||||
_ValueType;
|
||||
if (__is_pod(_ValueType))
|
||||
return std::copy(__first, __last, __result);
|
||||
else
|
||||
return std::__uninitialized_copy_aux(__first, __last, __result);
|
||||
}
|
||||
|
||||
// Valid if copy construction is equivalent to assignment, and if the
|
||||
// destructor is trivial.
|
||||
template<typename _ForwardIterator, typename _Tp>
|
||||
inline void
|
||||
__uninitialized_fill_aux(_ForwardIterator __first,
|
||||
_ForwardIterator __last,
|
||||
const _Tp& __x, __true_type)
|
||||
{ std::fill(__first, __last, __x); }
|
||||
|
||||
template<typename _ForwardIterator, typename _Tp>
|
||||
void
|
||||
__uninitialized_fill_aux(_ForwardIterator __first, _ForwardIterator __last,
|
||||
const _Tp& __x, __false_type)
|
||||
__uninitialized_fill_aux(_ForwardIterator __first,
|
||||
_ForwardIterator __last,
|
||||
const _Tp& __x)
|
||||
{
|
||||
_ForwardIterator __cur = __first;
|
||||
try
|
||||
@ -153,23 +140,19 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
||||
uninitialized_fill(_ForwardIterator __first, _ForwardIterator __last,
|
||||
const _Tp& __x)
|
||||
{
|
||||
typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType;
|
||||
typedef typename std::__is_scalar<_ValueType>::__type _Is_POD;
|
||||
std::__uninitialized_fill_aux(__first, __last, __x, _Is_POD());
|
||||
typedef typename iterator_traits<_ForwardIterator>::value_type
|
||||
_ValueType;
|
||||
if (__is_pod(_ValueType))
|
||||
std::fill(__first, __last, __x);
|
||||
else
|
||||
std::__uninitialized_fill_aux(__first, __last, __x);
|
||||
}
|
||||
|
||||
// Valid if copy construction is equivalent to assignment, and if the
|
||||
// destructor is trivial.
|
||||
template<typename _ForwardIterator, typename _Size, typename _Tp>
|
||||
inline void
|
||||
__uninitialized_fill_n_aux(_ForwardIterator __first, _Size __n,
|
||||
const _Tp& __x, __true_type)
|
||||
{ std::fill_n(__first, __n, __x); }
|
||||
|
||||
template<typename _ForwardIterator, typename _Size, typename _Tp>
|
||||
void
|
||||
__uninitialized_fill_n_aux(_ForwardIterator __first, _Size __n,
|
||||
const _Tp& __x, __false_type)
|
||||
const _Tp& __x)
|
||||
{
|
||||
_ForwardIterator __cur = __first;
|
||||
try
|
||||
@ -197,9 +180,12 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
||||
inline void
|
||||
uninitialized_fill_n(_ForwardIterator __first, _Size __n, const _Tp& __x)
|
||||
{
|
||||
typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType;
|
||||
typedef typename std::__is_scalar<_ValueType>::__type _Is_POD;
|
||||
std::__uninitialized_fill_n_aux(__first, __n, __x, _Is_POD());
|
||||
typedef typename iterator_traits<_ForwardIterator>::value_type
|
||||
_ValueType;
|
||||
if (__is_pod(_ValueType))
|
||||
std::fill_n(__first, __n, __x);
|
||||
else
|
||||
std::__uninitialized_fill_n_aux(__first, __n, __x);
|
||||
}
|
||||
|
||||
// Extensions: versions of uninitialized_copy, uninitialized_fill,
|
||||
|
Loading…
Reference in New Issue
Block a user