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