PR debug/81307
[official-gcc.git] / libstdc++-v3 / include / profile / deque
blobdb4274c22a19a23aa637b4f1fabbe5999570988c
1 // Profiling deque implementation -*- C++ -*-
3 // Copyright (C) 2009-2017 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.
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.
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.
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/>.
25 /** @file profile/deque
26  *  This file is a GNU profile extension to the Standard C++ Library.
27  */
29 #ifndef _GLIBCXX_PROFILE_DEQUE
30 #define _GLIBCXX_PROFILE_DEQUE 1
32 #include <deque>
34 namespace std _GLIBCXX_VISIBILITY(default)
36 namespace __profile
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;
45     public:
46       typedef typename _Base::size_type                 size_type;
47       typedef typename _Base::value_type                value_type;
49       // 23.2.1.1 construct/copy/destroy:
51 #if __cplusplus < 201103L
52       deque()
53       : _Base() { }
54       deque(const deque& __x)
55       : _Base(__x) { }
57       ~deque() { }
58 #else
59       deque() = default;
60       deque(const deque&) = default;
61       deque(deque&&) = default;
63       deque(const deque& __d, const _Allocator& __a)
64       : _Base(__d, __a) { }
66       deque(deque&& __d, const _Allocator& __a)
67       : _Base(std::move(__d), __a) { }
69       ~deque() = default;
71       deque(initializer_list<value_type> __l,
72             const _Allocator& __a = _Allocator())
73       : _Base(__l, __a) { }
74 #endif
76       explicit
77       deque(const _Allocator& __a)
78       : _Base(__a) { }
80 #if __cplusplus >= 201103L
81       explicit
82       deque(size_type __n, const _Allocator& __a = _Allocator())
83       : _Base(__n, __a) { }
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
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         { }
106       deque(const _Base& __x)
107       : _Base(__x) { }
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;
120       deque&
121       operator=(deque&&) = default;
123       deque&
124       operator=(initializer_list<value_type> __l)
125       {
126         _M_base() = __l;
127         return *this;
128       }
129 #endif
131       void
132       swap(deque& __x)
133       _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) )
134       { _Base::swap(__x); }
136       _Base&
137       _M_base() _GLIBCXX_NOEXCEPT       { return *this; }
139       const _Base&
140       _M_base() const _GLIBCXX_NOEXCEPT { return *this; }
141     };
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(); }
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(); }
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(); }
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(); }
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(); }
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(); }
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); }
185 } // namespace __profile
186 } // namespace std
188 #endif