c5d9ec5670
* include/bits/c++config (_GLIBCXX_NOEXCEPT_IF): Define. * include/bits/forward_list.h (forward_list::swap): Make noexcept unconditional. * include/bits/hashtable.h (_Hashtable::swap): Do not use _S_nothrow_swap(). * include/bits/stl_bvector.h (vector<bool>::swap): Make noexcept unconditional. * include/bits/stl_deque.h (deque::swap): Likewise. (swap(deque&, deque&)): Use _GLIBCXX_NOEXCEPT_IF. * include/bits/stl_list.h (list::swap): Make noexcept unconditional. (swap(list&, list&)): Use _GLIBCXX_NOEXCEPT_IF. * include/bits/stl_map.h (map::swap, swap(map&, map&)): Use _GLIBCXX_NOEXCEPT_IF, do not depend on _S_nothrow_swap. * include/bits/stl_multimap.h (multimap::swap, swap(multimap&, multimap&)): Likewise. * include/bits/stl_multiset.h (multiset::swap, swap(multiset&, multiset&)): Likewise. * include/bits/stl_set.h (set::swap, swap(set&, set&)): Likewise. * include/bits/stl_tree.h (_Rb_tree::swap, swap(_Rb_tree&, _Rb_tree&)): Likewise. * include/bits/stl_vector.h (vector::swap): Make noexcept unconditional. (swap(vector&, vector&)): Use _GLIBCXX_NOEXCEPT_IF. * include/debug/deque (deque::swap, swap): Likewise. * include/debug/forward_list (swap): Add noexcept. * include/debug/list (list::swap, swap): Use _GLIBCXX_NOEXCEPT_IF. * include/debug/map.h (map::swap, swap): Likewise. * include/debug/multimap.h (multimap::swap, swap): Likewise. * include/debug/multiset.h (multiset::Swap, swap): Likewise. * include/debug/set.h (set::swap, swap): Likewise. * include/debug/unordered_map (unordered_map::swap, unordered_multimap::swap, swap): Likewise. * include/debug/unordered_set (unordered_set::swap, unordered_multiset::swap, swap): Likewise. * include/debug/vector (vector::swap, swap): Likewise. * include/ext/alloc_traits.h (__alloc_traits::_S_nothrow_swap()): Remove. * include/profile/deque (deque::swap, swap): Use _GLIBCXX_NOEXCEPT_IF. * include/profile/forward_list (swap): Add noexcept. * include/profile/list (list::swap, swap) : Use _GLIBCXX_NOEXCEPT_IF. * include/profile/map.h (map::swap, swap): Likewise. * include/profile/multimap.h (multimap::swap, swap): Likewise. * include/profile/multiset.h (multiset::swap, swap): Likewise. * include/profile/set.h (set::swap, swap): Likewise. * include/profile/unordered_map (swap): Likewise. * include/profile/unordered_set (swap): Likewise. * include/profile/vector (vector::swap, swap): Likewise. Remove overloads for swapping rvalues. * testsuite/23_containers/deque/allocator/noexcept.cc: Update tests for noexcept on swap. * testsuite/23_containers/forward_list/allocator/noexcept.cc: Likewise. * testsuite/23_containers/list/allocator/noexcept.cc: Likewise. * testsuite/23_containers/map/allocator/noexcept.cc: Likewise. * testsuite/23_containers/multimap/allocator/noexcept.cc: Likewise. * testsuite/23_containers/multiset/allocator/noexcept.cc: Likewise. * testsuite/23_containers/set/allocator/noexcept.cc: Likewise. * testsuite/23_containers/unordered_map/allocator/noexcept.cc: Likewise. * testsuite/23_containers/unordered_multimap/allocator/noexcept.cc: Likewise. * testsuite/23_containers/unordered_multiset/allocator/noexcept.cc: Likewise. * testsuite/23_containers/unordered_set/allocator/noexcept.cc: Likewise. * testsuite/23_containers/vector/allocator/noexcept.cc: Likewise. * testsuite/23_containers/vector/bool/allocator/noexcept.cc: Likewise. * testsuite/ext/profile/mutex_extensions_neg.cc: Adjust dg-error line number. From-SVN: r225744
189 lines
5.1 KiB
C++
189 lines
5.1 KiB
C++
// Profiling deque implementation -*- C++ -*-
|
|
|
|
// Copyright (C) 2009-2015 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
|
|
// terms of the GNU General Public License as published by the
|
|
// Free Software Foundation; either version 3, or (at your option)
|
|
// any later version.
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
|
|
// Under Section 7 of GPL version 3, you are granted additional
|
|
// permissions described in the GCC Runtime Library Exception, version
|
|
// 3.1, as published by the Free Software Foundation.
|
|
|
|
// You should have received a copy of the GNU General Public License and
|
|
// a copy of the GCC Runtime Library Exception along with this program;
|
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|
// <http://www.gnu.org/licenses/>.
|
|
|
|
/** @file profile/deque
|
|
* This file is a GNU profile extension to the Standard C++ Library.
|
|
*/
|
|
|
|
#ifndef _GLIBCXX_PROFILE_DEQUE
|
|
#define _GLIBCXX_PROFILE_DEQUE 1
|
|
|
|
#include <deque>
|
|
|
|
namespace std _GLIBCXX_VISIBILITY(default)
|
|
{
|
|
namespace __profile
|
|
{
|
|
/// Class std::deque wrapper with performance instrumentation.
|
|
template<typename _Tp, typename _Allocator = std::allocator<_Tp> >
|
|
class deque
|
|
: public _GLIBCXX_STD_C::deque<_Tp, _Allocator>
|
|
{
|
|
typedef _GLIBCXX_STD_C::deque<_Tp, _Allocator> _Base;
|
|
|
|
public:
|
|
typedef typename _Base::size_type size_type;
|
|
typedef typename _Base::value_type value_type;
|
|
|
|
// 23.2.1.1 construct/copy/destroy:
|
|
|
|
#if __cplusplus < 201103L
|
|
deque()
|
|
: _Base() { }
|
|
deque(const deque& __x)
|
|
: _Base(__x) { }
|
|
|
|
~deque() { }
|
|
#else
|
|
deque() = default;
|
|
deque(const deque&) = default;
|
|
deque(deque&&) = default;
|
|
|
|
deque(const deque& __d, const _Allocator& __a)
|
|
: _Base(__d, __a) { }
|
|
|
|
deque(deque&& __d, const _Allocator& __a)
|
|
: _Base(std::move(__d), __a) { }
|
|
|
|
~deque() = default;
|
|
|
|
deque(initializer_list<value_type> __l,
|
|
const _Allocator& __a = _Allocator())
|
|
: _Base(__l, __a) { }
|
|
#endif
|
|
|
|
explicit
|
|
deque(const _Allocator& __a)
|
|
: _Base(__a) { }
|
|
|
|
#if __cplusplus >= 201103L
|
|
explicit
|
|
deque(size_type __n, const _Allocator& __a = _Allocator())
|
|
: _Base(__n, __a) { }
|
|
|
|
deque(size_type __n, const _Tp& __value,
|
|
const _Allocator& __a = _Allocator())
|
|
: _Base(__n, __value, __a) { }
|
|
#else
|
|
explicit
|
|
deque(size_type __n, const _Tp& __value = _Tp(),
|
|
const _Allocator& __a = _Allocator())
|
|
: _Base(__n, __value, __a) { }
|
|
#endif
|
|
|
|
#if __cplusplus >= 201103L
|
|
template<typename _InputIterator,
|
|
typename = std::_RequireInputIter<_InputIterator>>
|
|
#else
|
|
template<typename _InputIterator>
|
|
#endif
|
|
deque(_InputIterator __first, _InputIterator __last,
|
|
const _Allocator& __a = _Allocator())
|
|
: _Base(__first, __last, __a)
|
|
{ }
|
|
|
|
deque(const _Base& __x)
|
|
: _Base(__x) { }
|
|
|
|
#if __cplusplus < 201103L
|
|
deque&
|
|
operator=(const deque& __x)
|
|
{
|
|
_M_base() = __x;
|
|
return *this;
|
|
}
|
|
#else
|
|
deque&
|
|
operator=(const deque&) = default;
|
|
|
|
deque&
|
|
operator=(deque&&) = default;
|
|
|
|
deque&
|
|
operator=(initializer_list<value_type> __l)
|
|
{
|
|
_M_base() = __l;
|
|
return *this;
|
|
}
|
|
#endif
|
|
|
|
void
|
|
swap(deque& __x)
|
|
_GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) )
|
|
{ _Base::swap(__x); }
|
|
|
|
_Base&
|
|
_M_base() _GLIBCXX_NOEXCEPT { return *this; }
|
|
|
|
const _Base&
|
|
_M_base() const _GLIBCXX_NOEXCEPT { return *this; }
|
|
};
|
|
|
|
template<typename _Tp, typename _Alloc>
|
|
inline bool
|
|
operator==(const deque<_Tp, _Alloc>& __lhs,
|
|
const deque<_Tp, _Alloc>& __rhs)
|
|
{ return __lhs._M_base() == __rhs._M_base(); }
|
|
|
|
template<typename _Tp, typename _Alloc>
|
|
inline bool
|
|
operator!=(const deque<_Tp, _Alloc>& __lhs,
|
|
const deque<_Tp, _Alloc>& __rhs)
|
|
{ return __lhs._M_base() != __rhs._M_base(); }
|
|
|
|
template<typename _Tp, typename _Alloc>
|
|
inline bool
|
|
operator<(const deque<_Tp, _Alloc>& __lhs,
|
|
const deque<_Tp, _Alloc>& __rhs)
|
|
{ return __lhs._M_base() < __rhs._M_base(); }
|
|
|
|
template<typename _Tp, typename _Alloc>
|
|
inline bool
|
|
operator<=(const deque<_Tp, _Alloc>& __lhs,
|
|
const deque<_Tp, _Alloc>& __rhs)
|
|
{ return __lhs._M_base() <= __rhs._M_base(); }
|
|
|
|
template<typename _Tp, typename _Alloc>
|
|
inline bool
|
|
operator>=(const deque<_Tp, _Alloc>& __lhs,
|
|
const deque<_Tp, _Alloc>& __rhs)
|
|
{ return __lhs._M_base() >= __rhs._M_base(); }
|
|
|
|
template<typename _Tp, typename _Alloc>
|
|
inline bool
|
|
operator>(const deque<_Tp, _Alloc>& __lhs,
|
|
const deque<_Tp, _Alloc>& __rhs)
|
|
{ return __lhs._M_base() > __rhs._M_base(); }
|
|
|
|
template<typename _Tp, typename _Alloc>
|
|
inline void
|
|
swap(deque<_Tp, _Alloc>& __lhs, deque<_Tp, _Alloc>& __rhs)
|
|
_GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
|
|
{ __lhs.swap(__rhs); }
|
|
|
|
} // namespace __profile
|
|
} // namespace std
|
|
|
|
#endif
|