+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&):
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);
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);
// 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
#ifndef _STL_CONSTRUCT_H
#define _STL_CONSTRUCT_H 1
-#include <bits/cpp_type_traits.h>
#include <new>
_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
{
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);
}
/**
// 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
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>
_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).
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
: _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(...)
{
_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
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
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
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,