libstdc++
deque
Go to the documentation of this file.
00001 // Profiling deque implementation -*- C++ -*-
00002 
00003 // Copyright (C) 2009-2016 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       _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) )
00134       { _Base::swap(__x); }
00135 
00136       _Base&
00137       _M_base() _GLIBCXX_NOEXCEPT       { return *this; }
00138 
00139       const _Base&
00140       _M_base() const _GLIBCXX_NOEXCEPT { return *this; }
00141     };
00142 
00143   template<typename _Tp, typename _Alloc>
00144     inline bool
00145     operator==(const deque<_Tp, _Alloc>& __lhs,
00146                const deque<_Tp, _Alloc>& __rhs)
00147     { return __lhs._M_base() == __rhs._M_base(); }
00148 
00149   template<typename _Tp, typename _Alloc>
00150     inline bool
00151     operator!=(const deque<_Tp, _Alloc>& __lhs,
00152                const deque<_Tp, _Alloc>& __rhs)
00153     { return __lhs._M_base() != __rhs._M_base(); }
00154 
00155   template<typename _Tp, typename _Alloc>
00156     inline bool
00157     operator<(const deque<_Tp, _Alloc>& __lhs,
00158               const deque<_Tp, _Alloc>& __rhs)
00159     { return __lhs._M_base() < __rhs._M_base(); }
00160 
00161   template<typename _Tp, typename _Alloc>
00162     inline bool
00163     operator<=(const deque<_Tp, _Alloc>& __lhs,
00164                const deque<_Tp, _Alloc>& __rhs)
00165     { return __lhs._M_base() <= __rhs._M_base(); }
00166 
00167   template<typename _Tp, typename _Alloc>
00168     inline bool
00169     operator>=(const deque<_Tp, _Alloc>& __lhs,
00170                const deque<_Tp, _Alloc>& __rhs)
00171     { return __lhs._M_base() >= __rhs._M_base(); }
00172 
00173   template<typename _Tp, typename _Alloc>
00174     inline bool
00175     operator>(const deque<_Tp, _Alloc>& __lhs,
00176               const deque<_Tp, _Alloc>& __rhs)
00177     { return __lhs._M_base() > __rhs._M_base(); }
00178 
00179   template<typename _Tp, typename _Alloc>
00180     inline void
00181     swap(deque<_Tp, _Alloc>& __lhs, deque<_Tp, _Alloc>& __rhs)
00182     _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
00183     { __lhs.swap(__rhs); }
00184 
00185 } // namespace __profile
00186 } // namespace std
00187 
00188 #endif