libstdc++
|
00001 // Profiling deque implementation -*- C++ -*- 00002 00003 // Copyright (C) 2009-2015 Free Software Foundation, Inc. 00004 // 00005 // This file is part of the GNU ISO C++ Library. This library is free 00006 // software; you can redistribute it and/or modify it under the 00007 // terms of the GNU General Public License as published by the 00008 // Free Software Foundation; either version 3, or (at your option) 00009 // any later version. 00010 00011 // This library is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU General Public License for more details. 00015 00016 // Under Section 7 of GPL version 3, you are granted additional 00017 // permissions described in the GCC Runtime Library Exception, version 00018 // 3.1, as published by the Free Software Foundation. 00019 00020 // You should have received a copy of the GNU General Public License and 00021 // a copy of the GCC Runtime Library Exception along with this program; 00022 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 00023 // <http://www.gnu.org/licenses/>. 00024 00025 /** @file profile/deque 00026 * This file is a GNU profile extension to the Standard C++ Library. 00027 */ 00028 00029 #ifndef _GLIBCXX_PROFILE_DEQUE 00030 #define _GLIBCXX_PROFILE_DEQUE 1 00031 00032 #include <deque> 00033 00034 namespace std _GLIBCXX_VISIBILITY(default) 00035 { 00036 namespace __profile 00037 { 00038 /// Class std::deque wrapper with performance instrumentation. 00039 template<typename _Tp, typename _Allocator = std::allocator<_Tp> > 00040 class deque 00041 : public _GLIBCXX_STD_C::deque<_Tp, _Allocator> 00042 { 00043 typedef _GLIBCXX_STD_C::deque<_Tp, _Allocator> _Base; 00044 00045 public: 00046 typedef typename _Base::size_type size_type; 00047 typedef typename _Base::value_type value_type; 00048 00049 // 23.2.1.1 construct/copy/destroy: 00050 00051 #if __cplusplus < 201103L 00052 deque() 00053 : _Base() { } 00054 deque(const deque& __x) 00055 : _Base(__x) { } 00056 00057 ~deque() { } 00058 #else 00059 deque() = default; 00060 deque(const deque&) = default; 00061 deque(deque&&) = default; 00062 00063 deque(const deque& __d, const _Allocator& __a) 00064 : _Base(__d, __a) { } 00065 00066 deque(deque&& __d, const _Allocator& __a) 00067 : _Base(std::move(__d), __a) { } 00068 00069 ~deque() = default; 00070 00071 deque(initializer_list<value_type> __l, 00072 const _Allocator& __a = _Allocator()) 00073 : _Base(__l, __a) { } 00074 #endif 00075 00076 explicit 00077 deque(const _Allocator& __a) 00078 : _Base(__a) { } 00079 00080 #if __cplusplus >= 201103L 00081 explicit 00082 deque(size_type __n, const _Allocator& __a = _Allocator()) 00083 : _Base(__n, __a) { } 00084 00085 deque(size_type __n, const _Tp& __value, 00086 const _Allocator& __a = _Allocator()) 00087 : _Base(__n, __value, __a) { } 00088 #else 00089 explicit 00090 deque(size_type __n, const _Tp& __value = _Tp(), 00091 const _Allocator& __a = _Allocator()) 00092 : _Base(__n, __value, __a) { } 00093 #endif 00094 00095 #if __cplusplus >= 201103L 00096 template<typename _InputIterator, 00097 typename = std::_RequireInputIter<_InputIterator>> 00098 #else 00099 template<typename _InputIterator> 00100 #endif 00101 deque(_InputIterator __first, _InputIterator __last, 00102 const _Allocator& __a = _Allocator()) 00103 : _Base(__first, __last, __a) 00104 { } 00105 00106 deque(const _Base& __x) 00107 : _Base(__x) { } 00108 00109 #if __cplusplus < 201103L 00110 deque& 00111 operator=(const deque& __x) 00112 { 00113 _M_base() = __x; 00114 return *this; 00115 } 00116 #else 00117 deque& 00118 operator=(const deque&) = default; 00119 00120 deque& 00121 operator=(deque&&) = default; 00122 00123 deque& 00124 operator=(initializer_list<value_type> __l) 00125 { 00126 _M_base() = __l; 00127 return *this; 00128 } 00129 #endif 00130 00131 void 00132 swap(deque& __x) 00133 #if __cplusplus >= 201103L 00134 noexcept( noexcept(declval<_Base>().swap(__x)) ) 00135 #endif 00136 { _Base::swap(__x); } 00137 00138 _Base& 00139 _M_base() _GLIBCXX_NOEXCEPT { return *this; } 00140 00141 const _Base& 00142 _M_base() const _GLIBCXX_NOEXCEPT { return *this; } 00143 }; 00144 00145 template<typename _Tp, typename _Alloc> 00146 inline bool 00147 operator==(const deque<_Tp, _Alloc>& __lhs, 00148 const deque<_Tp, _Alloc>& __rhs) 00149 { return __lhs._M_base() == __rhs._M_base(); } 00150 00151 template<typename _Tp, typename _Alloc> 00152 inline bool 00153 operator!=(const deque<_Tp, _Alloc>& __lhs, 00154 const deque<_Tp, _Alloc>& __rhs) 00155 { return __lhs._M_base() != __rhs._M_base(); } 00156 00157 template<typename _Tp, typename _Alloc> 00158 inline bool 00159 operator<(const deque<_Tp, _Alloc>& __lhs, 00160 const deque<_Tp, _Alloc>& __rhs) 00161 { return __lhs._M_base() < __rhs._M_base(); } 00162 00163 template<typename _Tp, typename _Alloc> 00164 inline bool 00165 operator<=(const deque<_Tp, _Alloc>& __lhs, 00166 const deque<_Tp, _Alloc>& __rhs) 00167 { return __lhs._M_base() <= __rhs._M_base(); } 00168 00169 template<typename _Tp, typename _Alloc> 00170 inline bool 00171 operator>=(const deque<_Tp, _Alloc>& __lhs, 00172 const deque<_Tp, _Alloc>& __rhs) 00173 { return __lhs._M_base() >= __rhs._M_base(); } 00174 00175 template<typename _Tp, typename _Alloc> 00176 inline bool 00177 operator>(const deque<_Tp, _Alloc>& __lhs, 00178 const deque<_Tp, _Alloc>& __rhs) 00179 { return __lhs._M_base() > __rhs._M_base(); } 00180 00181 template<typename _Tp, typename _Alloc> 00182 inline void 00183 swap(deque<_Tp, _Alloc>& __lhs, deque<_Tp, _Alloc>& __rhs) 00184 { __lhs.swap(__rhs); } 00185 00186 } // namespace __profile 00187 } // namespace std 00188 00189 #endif