1// Profiling deque implementation -*- C++ -*- 2 3// Copyright (C) 2009-2019 Free Software Foundation, Inc. 4// 5// This file is part of the GNU ISO C++ Library. This library is free 6// software; you can redistribute it and/or modify it under the 7// terms of the GNU General Public License as published by the 8// Free Software Foundation; either version 3, or (at your option) 9// any later version. 10 11// This library is distributed in the hope that it will be useful, 12// but WITHOUT ANY WARRANTY; without even the implied warranty of 13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14// GNU General Public License for more details. 15 16// Under Section 7 of GPL version 3, you are granted additional 17// permissions described in the GCC Runtime Library Exception, version 18// 3.1, as published by the Free Software Foundation. 19 20// You should have received a copy of the GNU General Public License and 21// a copy of the GCC Runtime Library Exception along with this program; 22// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 23// <http://www.gnu.org/licenses/>. 24 25/** @file profile/deque 26 * This file is a GNU profile extension to the Standard C++ Library. 27 */ 28 29#ifndef _GLIBCXX_PROFILE_DEQUE 30#define _GLIBCXX_PROFILE_DEQUE 1 31 32#include <deque> 33 34namespace std _GLIBCXX_VISIBILITY(default) 35{ 36namespace __profile 37{ 38 /// Class std::deque wrapper with performance instrumentation. 39 template<typename _Tp, typename _Allocator = std::allocator<_Tp> > 40 class deque 41 : public _GLIBCXX_STD_C::deque<_Tp, _Allocator> 42 { 43 typedef _GLIBCXX_STD_C::deque<_Tp, _Allocator> _Base; 44 45 public: 46 typedef typename _Base::size_type size_type; 47 typedef typename _Base::value_type value_type; 48 49 // 23.2.1.1 construct/copy/destroy: 50 51#if __cplusplus < 201103L 52 deque() 53 : _Base() { } 54 deque(const deque& __x) 55 : _Base(__x) { } 56 57 ~deque() { } 58#else 59 deque() = default; 60 deque(const deque&) = default; 61 deque(deque&&) = default; 62 63 deque(const deque& __d, const _Allocator& __a) 64 : _Base(__d, __a) { } 65 66 deque(deque&& __d, const _Allocator& __a) 67 : _Base(std::move(__d), __a) { } 68 69 ~deque() = default; 70 71 deque(initializer_list<value_type> __l, 72 const _Allocator& __a = _Allocator()) 73 : _Base(__l, __a) { } 74#endif 75 76 explicit 77 deque(const _Allocator& __a) 78 : _Base(__a) { } 79 80#if __cplusplus >= 201103L 81 explicit 82 deque(size_type __n, const _Allocator& __a = _Allocator()) 83 : _Base(__n, __a) { } 84 85 deque(size_type __n, const _Tp& __value, 86 const _Allocator& __a = _Allocator()) 87 : _Base(__n, __value, __a) { } 88#else 89 explicit 90 deque(size_type __n, const _Tp& __value = _Tp(), 91 const _Allocator& __a = _Allocator()) 92 : _Base(__n, __value, __a) { } 93#endif 94 95#if __cplusplus >= 201103L 96 template<typename _InputIterator, 97 typename = std::_RequireInputIter<_InputIterator>> 98#else 99 template<typename _InputIterator> 100#endif 101 deque(_InputIterator __first, _InputIterator __last, 102 const _Allocator& __a = _Allocator()) 103 : _Base(__first, __last, __a) 104 { } 105 106 deque(const _Base& __x) 107 : _Base(__x) { } 108 109#if __cplusplus < 201103L 110 deque& 111 operator=(const deque& __x) 112 { 113 _M_base() = __x; 114 return *this; 115 } 116#else 117 deque& 118 operator=(const deque&) = default; 119 120 deque& 121 operator=(deque&&) = default; 122 123 deque& 124 operator=(initializer_list<value_type> __l) 125 { 126 _M_base() = __l; 127 return *this; 128 } 129#endif 130 131 void 132 swap(deque& __x) 133 _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) ) 134 { _Base::swap(__x); } 135 136 _Base& 137 _M_base() _GLIBCXX_NOEXCEPT { return *this; } 138 139 const _Base& 140 _M_base() const _GLIBCXX_NOEXCEPT { return *this; } 141 }; 142 143 template<typename _Tp, typename _Alloc> 144 inline bool 145 operator==(const deque<_Tp, _Alloc>& __lhs, 146 const deque<_Tp, _Alloc>& __rhs) 147 { return __lhs._M_base() == __rhs._M_base(); } 148 149 template<typename _Tp, typename _Alloc> 150 inline bool 151 operator!=(const deque<_Tp, _Alloc>& __lhs, 152 const deque<_Tp, _Alloc>& __rhs) 153 { return __lhs._M_base() != __rhs._M_base(); } 154 155 template<typename _Tp, typename _Alloc> 156 inline bool 157 operator<(const deque<_Tp, _Alloc>& __lhs, 158 const deque<_Tp, _Alloc>& __rhs) 159 { return __lhs._M_base() < __rhs._M_base(); } 160 161 template<typename _Tp, typename _Alloc> 162 inline bool 163 operator<=(const deque<_Tp, _Alloc>& __lhs, 164 const deque<_Tp, _Alloc>& __rhs) 165 { return __lhs._M_base() <= __rhs._M_base(); } 166 167 template<typename _Tp, typename _Alloc> 168 inline bool 169 operator>=(const deque<_Tp, _Alloc>& __lhs, 170 const deque<_Tp, _Alloc>& __rhs) 171 { return __lhs._M_base() >= __rhs._M_base(); } 172 173 template<typename _Tp, typename _Alloc> 174 inline bool 175 operator>(const deque<_Tp, _Alloc>& __lhs, 176 const deque<_Tp, _Alloc>& __rhs) 177 { return __lhs._M_base() > __rhs._M_base(); } 178 179 template<typename _Tp, typename _Alloc> 180 inline void 181 swap(deque<_Tp, _Alloc>& __lhs, deque<_Tp, _Alloc>& __rhs) 182 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs))) 183 { __lhs.swap(__rhs); } 184 185} // namespace __profile 186} // namespace std 187 188#endif 189