]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
stl_algobase.h (__copy_aux(_II, _II, _OI), [...]): Use __is_pod.
authorPaolo Carlini <pcarlini@suse.de>
Tue, 3 Apr 2007 18:44:01 +0000 (18:44 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Tue, 3 Apr 2007 18:44:01 +0000 (18:44 +0000)
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

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/stl_algobase.h
libstdc++-v3/include/bits/stl_construct.h
libstdc++-v3/include/bits/stl_deque.h
libstdc++-v3/include/bits/stl_tempbuf.h
libstdc++-v3/include/bits/stl_uninitialized.h

index a2f10f4654f3a47a873e5662a7aeaf1f48ab5dbd..96628b9d355ec99f5a7889d9f59c6f3e1e0778eb 100644 (file)
@@ -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&):
index 480557274c2e9675ba34110ac756e1f53784dabb..0c4c01deaf3a34d9c7c8aa3cf3533a0422414c2a 100644 (file)
@@ -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);
index 0a03fb72d3f0803cd14fc713ffdaede9d4e8cddd..d80ade782f0bdc7cfeee214cf2ba6c6690a02775 100644 (file)
@@ -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);
     }
 
   /**
index 9da0bb7ea79ed23ee582fbeec0939d3b047ae197..2030a937e5cfa6620832d60afea948e461c6dabe 100644 (file)
@@ -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).
index 6c64c3fe56a84d8d656f3d28b6ad0ff5c7c4b8c2..5663844f143d5e0bf28e4099d08b07b0807fe65a 100644 (file)
@@ -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(...)
        {
index a8dbb01ff6b5a7c3b742fcd37e64b6ac2c39140a..c460a56d021a87605ec337eb1c30802bb357b3c3 100644 (file)
 
 _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,