summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2007-04-03 18:44:01 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2007-04-03 18:44:01 +0000
commit6e4355c2ac20048cead81b6266eae5c4005e4dbb (patch)
tree4fe19eefc2fde92de4ada47d288626aefe08011d
parentf513cec0a4bd08180c33a95b6d4c13ae3108c7be (diff)
downloadgcc-6e4355c2ac20048cead81b6266eae5c4005e4dbb.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@123480 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--libstdc++-v3/ChangeLog18
-rw-r--r--libstdc++-v3/include/bits/stl_algobase.h4
-rw-r--r--libstdc++-v3/include/bits/stl_construct.h41
-rw-r--r--libstdc++-v3/include/bits/stl_deque.h14
-rw-r--r--libstdc++-v3/include/bits/stl_tempbuf.h14
-rw-r--r--libstdc++-v3/include/bits/stl_uninitialized.h66
6 files changed, 56 insertions, 101 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index a2f10f4654f..96628b9d355 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,23 @@
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&):
Uglify parameter.
diff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h
index 480557274c2..0c4c01deaf3 100644
--- a/libstdc++-v3/include/bits/stl_algobase.h
+++ b/libstdc++-v3/include/bits/stl_algobase.h
@@ -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);
diff --git a/libstdc++-v3/include/bits/stl_construct.h b/libstdc++-v3/include/bits/stl_construct.h
index 0a03fb72d3f..d80ade782f0 100644
--- a/libstdc++-v3/include/bits/stl_construct.h
+++ b/libstdc++-v3/include/bits/stl_construct.h
@@ -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)
@@ -108,36 +108,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
/**
* @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
* a trivial destructor, the compiler should optimize all of this
* away, otherwise the objects' destructors must be invoked.
@@ -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);
}
/**
diff --git a/libstdc++-v3/include/bits/stl_deque.h b/libstdc++-v3/include/bits/stl_deque.h
index 9da0bb7ea79..2030a937e5c 100644
--- a/libstdc++-v3/include/bits/stl_deque.h
+++ b/libstdc++-v3/include/bits/stl_deque.h
@@ -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).
diff --git a/libstdc++-v3/include/bits/stl_tempbuf.h b/libstdc++-v3/include/bits/stl_tempbuf.h
index 6c64c3fe56a..5663844f143 100644
--- a/libstdc++-v3/include/bits/stl_tempbuf.h
+++ b/libstdc++-v3/include/bits/stl_tempbuf.h
@@ -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(...)
{
diff --git a/libstdc++-v3/include/bits/stl_uninitialized.h b/libstdc++-v3/include/bits/stl_uninitialized.h
index a8dbb01ff6b..c460a56d021 100644
--- a/libstdc++-v3/include/bits/stl_uninitialized.h
+++ b/libstdc++-v3/include/bits/stl_uninitialized.h
@@ -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,