xref: /dflybsd-src/contrib/gcc-8.0/libstdc++-v3/include/profile/map.h (revision 38fd149817dfbff97799f62fcb70be98c4e32523)
1*38fd1498Szrj // Profiling map 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 along
21*38fd1498Szrj // with this library; see the file COPYING3.  If not see
22*38fd1498Szrj // <http://www.gnu.org/licenses/>.
23*38fd1498Szrj 
24*38fd1498Szrj /** @file profile/map.h
25*38fd1498Szrj  *  This file is a GNU profile extension to the Standard C++ Library.
26*38fd1498Szrj  */
27*38fd1498Szrj 
28*38fd1498Szrj #ifndef _GLIBCXX_PROFILE_MAP_H
29*38fd1498Szrj #define _GLIBCXX_PROFILE_MAP_H 1
30*38fd1498Szrj 
31*38fd1498Szrj #include <profile/base.h>
32*38fd1498Szrj #include <profile/ordered_base.h>
33*38fd1498Szrj 
_GLIBCXX_VISIBILITY(default)34*38fd1498Szrj namespace std _GLIBCXX_VISIBILITY(default)
35*38fd1498Szrj {
36*38fd1498Szrj namespace __profile
37*38fd1498Szrj {
38*38fd1498Szrj   /// Class std::map wrapper with performance instrumentation.
39*38fd1498Szrj   template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
40*38fd1498Szrj 	   typename _Allocator = std::allocator<std::pair<const _Key, _Tp> > >
41*38fd1498Szrj     class map
42*38fd1498Szrj     : public _GLIBCXX_STD_C::map<_Key, _Tp, _Compare, _Allocator>,
43*38fd1498Szrj       public _Ordered_profile<map<_Key, _Tp, _Compare, _Allocator> >
44*38fd1498Szrj     {
45*38fd1498Szrj       typedef _GLIBCXX_STD_C::map<_Key, _Tp, _Compare, _Allocator> _Base;
46*38fd1498Szrj 
47*38fd1498Szrj       typedef typename _Base::iterator			_Base_iterator;
48*38fd1498Szrj       typedef typename _Base::const_iterator		_Base_const_iterator;
49*38fd1498Szrj 
50*38fd1498Szrj     public:
51*38fd1498Szrj       // types:
52*38fd1498Szrj       typedef _Key					key_type;
53*38fd1498Szrj       typedef _Tp					mapped_type;
54*38fd1498Szrj       typedef typename _Base::value_type		value_type;
55*38fd1498Szrj       typedef _Compare					key_compare;
56*38fd1498Szrj       typedef typename _Base::reference			reference;
57*38fd1498Szrj       typedef typename _Base::const_reference		const_reference;
58*38fd1498Szrj 
59*38fd1498Szrj       typedef __iterator_tracker<_Base_iterator, map>	iterator;
60*38fd1498Szrj       typedef __iterator_tracker<_Base_const_iterator,
61*38fd1498Szrj 				 map>			const_iterator;
62*38fd1498Szrj       typedef std::reverse_iterator<iterator>		reverse_iterator;
63*38fd1498Szrj       typedef std::reverse_iterator<const_iterator>	const_reverse_iterator;
64*38fd1498Szrj 
65*38fd1498Szrj       typedef typename _Base::size_type			size_type;
66*38fd1498Szrj       typedef typename _Base::difference_type		difference_type;
67*38fd1498Szrj 
68*38fd1498Szrj       // 23.3.1.1 construct/copy/destroy:
69*38fd1498Szrj 
70*38fd1498Szrj #if __cplusplus < 201103L
71*38fd1498Szrj       map()
72*38fd1498Szrj       : _Base() { }
73*38fd1498Szrj       map(const map& __x)
74*38fd1498Szrj 	: _Base(__x) { }
75*38fd1498Szrj       ~map()
76*38fd1498Szrj       { }
77*38fd1498Szrj #else
78*38fd1498Szrj       map() = default;
79*38fd1498Szrj       map(const map&) = default;
80*38fd1498Szrj       map(map&&) = default;
81*38fd1498Szrj       ~map() = default;
82*38fd1498Szrj #endif
83*38fd1498Szrj 
84*38fd1498Szrj       explicit
85*38fd1498Szrj       map(const _Compare& __comp,
86*38fd1498Szrj 	  const _Allocator& __a = _Allocator())
87*38fd1498Szrj       : _Base(__comp, __a) { }
88*38fd1498Szrj 
89*38fd1498Szrj #if __cplusplus >= 201103L
90*38fd1498Szrj       template<typename _InputIterator,
91*38fd1498Szrj 	       typename = std::_RequireInputIter<_InputIterator>>
92*38fd1498Szrj #else
93*38fd1498Szrj       template<typename _InputIterator>
94*38fd1498Szrj #endif
95*38fd1498Szrj 	map(_InputIterator __first, _InputIterator __last,
96*38fd1498Szrj 	    const _Compare& __comp = _Compare(),
97*38fd1498Szrj 	    const _Allocator& __a = _Allocator())
98*38fd1498Szrj 	: _Base(__first, __last, __comp, __a) { }
99*38fd1498Szrj 
100*38fd1498Szrj       map(const _Base& __x)
101*38fd1498Szrj       : _Base(__x) { }
102*38fd1498Szrj 
103*38fd1498Szrj #if __cplusplus >= 201103L
104*38fd1498Szrj       map(initializer_list<value_type> __l,
105*38fd1498Szrj 	  const _Compare& __c = _Compare(),
106*38fd1498Szrj 	  const _Allocator& __a = _Allocator())
107*38fd1498Szrj       : _Base(__l, __c, __a) { }
108*38fd1498Szrj 
109*38fd1498Szrj       explicit
110*38fd1498Szrj       map(const _Allocator& __a)
111*38fd1498Szrj       : _Base(__a) { }
112*38fd1498Szrj 
113*38fd1498Szrj       map(const map& __x, const _Allocator& __a)
114*38fd1498Szrj       : _Base(__x, __a) { }
115*38fd1498Szrj 
116*38fd1498Szrj       map(map&& __x, const _Allocator& __a)
117*38fd1498Szrj       noexcept( noexcept(_Base(std::move(__x), __a)) )
118*38fd1498Szrj       : _Base(std::move(__x), __a) { }
119*38fd1498Szrj 
120*38fd1498Szrj       map(initializer_list<value_type> __l, const _Allocator& __a)
121*38fd1498Szrj       : _Base(__l, __a) { }
122*38fd1498Szrj 
123*38fd1498Szrj       template<typename _InputIterator>
124*38fd1498Szrj 	map(_InputIterator __first, _InputIterator __last,
125*38fd1498Szrj 	    const _Allocator& __a)
126*38fd1498Szrj 	: _Base(__first, __last, __a) { }
127*38fd1498Szrj #endif
128*38fd1498Szrj 
129*38fd1498Szrj #if __cplusplus < 201103L
130*38fd1498Szrj       map&
131*38fd1498Szrj       operator=(const map& __x)
132*38fd1498Szrj       {
133*38fd1498Szrj 	this->_M_profile_destruct();
134*38fd1498Szrj 	_M_base() = __x;
135*38fd1498Szrj 	this->_M_profile_construct();
136*38fd1498Szrj 	return *this;
137*38fd1498Szrj       }
138*38fd1498Szrj #else
139*38fd1498Szrj       map&
140*38fd1498Szrj       operator=(const map&) = default;
141*38fd1498Szrj 
142*38fd1498Szrj       map&
143*38fd1498Szrj       operator=(map&&) = default;
144*38fd1498Szrj 
145*38fd1498Szrj       map&
146*38fd1498Szrj       operator=(initializer_list<value_type> __l)
147*38fd1498Szrj       {
148*38fd1498Szrj 	this->_M_profile_destruct();
149*38fd1498Szrj 	_M_base() = __l;
150*38fd1498Szrj 	this->_M_profile_construct();
151*38fd1498Szrj 	return *this;
152*38fd1498Szrj       }
153*38fd1498Szrj #endif
154*38fd1498Szrj 
155*38fd1498Szrj       // iterators
156*38fd1498Szrj       iterator
157*38fd1498Szrj       begin() _GLIBCXX_NOEXCEPT
158*38fd1498Szrj       { return iterator(_Base::begin(), this); }
159*38fd1498Szrj 
160*38fd1498Szrj       const_iterator
161*38fd1498Szrj       begin() const _GLIBCXX_NOEXCEPT
162*38fd1498Szrj       { return const_iterator(_Base::begin(), this); }
163*38fd1498Szrj 
164*38fd1498Szrj       iterator
165*38fd1498Szrj       end() _GLIBCXX_NOEXCEPT
166*38fd1498Szrj       { return iterator(_Base::end(), this); }
167*38fd1498Szrj 
168*38fd1498Szrj       const_iterator
169*38fd1498Szrj       end() const _GLIBCXX_NOEXCEPT
170*38fd1498Szrj       { return const_iterator(_Base::end(), this); }
171*38fd1498Szrj 
172*38fd1498Szrj #if __cplusplus >= 201103L
173*38fd1498Szrj       const_iterator
174*38fd1498Szrj       cbegin() const noexcept
175*38fd1498Szrj       { return const_iterator(_Base::cbegin(), this); }
176*38fd1498Szrj 
177*38fd1498Szrj       const_iterator
178*38fd1498Szrj       cend() const noexcept
179*38fd1498Szrj       { return const_iterator(_Base::cend(), this); }
180*38fd1498Szrj #endif
181*38fd1498Szrj 
182*38fd1498Szrj       reverse_iterator
183*38fd1498Szrj       rbegin() _GLIBCXX_NOEXCEPT
184*38fd1498Szrj       {
185*38fd1498Szrj 	__profcxx_map2umap_invalidate(this->_M_map2umap_info);
186*38fd1498Szrj 	return reverse_iterator(end());
187*38fd1498Szrj       }
188*38fd1498Szrj 
189*38fd1498Szrj       const_reverse_iterator
190*38fd1498Szrj       rbegin() const _GLIBCXX_NOEXCEPT
191*38fd1498Szrj       {
192*38fd1498Szrj 	__profcxx_map2umap_invalidate(this->_M_map2umap_info);
193*38fd1498Szrj 	return const_reverse_iterator(end());
194*38fd1498Szrj       }
195*38fd1498Szrj 
196*38fd1498Szrj       reverse_iterator
197*38fd1498Szrj       rend() _GLIBCXX_NOEXCEPT
198*38fd1498Szrj       {
199*38fd1498Szrj 	__profcxx_map2umap_invalidate(this->_M_map2umap_info);
200*38fd1498Szrj 	return reverse_iterator(begin());
201*38fd1498Szrj       }
202*38fd1498Szrj 
203*38fd1498Szrj       const_reverse_iterator
204*38fd1498Szrj       rend() const _GLIBCXX_NOEXCEPT
205*38fd1498Szrj       {
206*38fd1498Szrj 	__profcxx_map2umap_invalidate(this->_M_map2umap_info);
207*38fd1498Szrj 	return const_reverse_iterator(begin());
208*38fd1498Szrj       }
209*38fd1498Szrj 
210*38fd1498Szrj #if __cplusplus >= 201103L
211*38fd1498Szrj       const_reverse_iterator
212*38fd1498Szrj       crbegin() const noexcept
213*38fd1498Szrj       {
214*38fd1498Szrj 	__profcxx_map2umap_invalidate(this->_M_map2umap_info);
215*38fd1498Szrj 	return const_reverse_iterator(cend());
216*38fd1498Szrj       }
217*38fd1498Szrj 
218*38fd1498Szrj       const_reverse_iterator
219*38fd1498Szrj       crend() const noexcept
220*38fd1498Szrj       {
221*38fd1498Szrj 	__profcxx_map2umap_invalidate(this->_M_map2umap_info);
222*38fd1498Szrj 	return const_reverse_iterator(cbegin());
223*38fd1498Szrj       }
224*38fd1498Szrj #endif
225*38fd1498Szrj 
226*38fd1498Szrj       // 23.3.1.2 element access:
227*38fd1498Szrj       mapped_type&
228*38fd1498Szrj       operator[](const key_type& __k)
229*38fd1498Szrj       {
230*38fd1498Szrj 	__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
231*38fd1498Szrj 	return _Base::operator[](__k);
232*38fd1498Szrj       }
233*38fd1498Szrj 
234*38fd1498Szrj #if __cplusplus >= 201103L
235*38fd1498Szrj       mapped_type&
236*38fd1498Szrj       operator[](key_type&& __k)
237*38fd1498Szrj       {
238*38fd1498Szrj 	__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
239*38fd1498Szrj 	return _Base::operator[](std::move(__k));
240*38fd1498Szrj       }
241*38fd1498Szrj #endif
242*38fd1498Szrj 
243*38fd1498Szrj       mapped_type&
244*38fd1498Szrj       at(const key_type& __k)
245*38fd1498Szrj       {
246*38fd1498Szrj 	__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
247*38fd1498Szrj 	return _Base::at(__k);
248*38fd1498Szrj       }
249*38fd1498Szrj 
250*38fd1498Szrj       const mapped_type&
251*38fd1498Szrj       at(const key_type& __k) const
252*38fd1498Szrj       {
253*38fd1498Szrj 	__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
254*38fd1498Szrj 	return _Base::at(__k);
255*38fd1498Szrj       }
256*38fd1498Szrj 
257*38fd1498Szrj       // modifiers:
258*38fd1498Szrj #if __cplusplus >= 201103L
259*38fd1498Szrj       template<typename... _Args>
260*38fd1498Szrj 	std::pair<iterator, bool>
261*38fd1498Szrj 	emplace(_Args&&... __args)
262*38fd1498Szrj 	{
263*38fd1498Szrj 	  // The cost is the same whether or not the element is inserted so we
264*38fd1498Szrj 	  // always report insertion of 1 element.
265*38fd1498Szrj 	  __profcxx_map2umap_insert(this->_M_map2umap_info, this->size(), 1);
266*38fd1498Szrj 	  auto __base_ret = _Base::emplace(std::forward<_Args>(__args)...);
267*38fd1498Szrj 	  return std::make_pair(iterator(__base_ret.first, this),
268*38fd1498Szrj 				__base_ret.second);
269*38fd1498Szrj 	}
270*38fd1498Szrj 
271*38fd1498Szrj       template<typename... _Args>
272*38fd1498Szrj 	iterator
273*38fd1498Szrj 	emplace_hint(const_iterator __pos, _Args&&... __args)
274*38fd1498Szrj 	{
275*38fd1498Szrj 	  auto size_before = this->size();
276*38fd1498Szrj 	  auto __res
277*38fd1498Szrj 	    = _Base::emplace_hint(__pos.base(), std::forward<_Args>(__args)...);
278*38fd1498Szrj 	  __profcxx_map2umap_insert(this->_M_map2umap_info,
279*38fd1498Szrj 		size_before, _M_hint_used(__pos.base(), __res) ? 0 : 1);
280*38fd1498Szrj 	  return iterator(__res, this);
281*38fd1498Szrj 	}
282*38fd1498Szrj #endif
283*38fd1498Szrj 
284*38fd1498Szrj       std::pair<iterator, bool>
285*38fd1498Szrj       insert(const value_type& __x)
286*38fd1498Szrj       {
287*38fd1498Szrj 	__profcxx_map2umap_insert(this->_M_map2umap_info, this->size(), 1);
288*38fd1498Szrj 	std::pair<_Base_iterator, bool> __base_ret = _Base::insert(__x);
289*38fd1498Szrj 	return std::make_pair(iterator(__base_ret.first, this),
290*38fd1498Szrj 			      __base_ret.second);
291*38fd1498Szrj       }
292*38fd1498Szrj 
293*38fd1498Szrj #if __cplusplus >= 201103L
294*38fd1498Szrj       template<typename _Pair, typename = typename
295*38fd1498Szrj 	       std::enable_if<std::is_constructible<value_type,
296*38fd1498Szrj 						    _Pair&&>::value>::type>
297*38fd1498Szrj 	std::pair<iterator, bool>
298*38fd1498Szrj 	insert(_Pair&& __x)
299*38fd1498Szrj 	{
300*38fd1498Szrj 	  __profcxx_map2umap_insert(this->_M_map2umap_info, this->size(), 1);
301*38fd1498Szrj 	  auto __base_ret= _Base::insert(std::forward<_Pair>(__x));
302*38fd1498Szrj 	  return std::make_pair(iterator(__base_ret.first, this),
303*38fd1498Szrj 				__base_ret.second);
304*38fd1498Szrj 	}
305*38fd1498Szrj #endif
306*38fd1498Szrj 
307*38fd1498Szrj #if __cplusplus >= 201103L
308*38fd1498Szrj       void
309*38fd1498Szrj       insert(std::initializer_list<value_type> __list)
310*38fd1498Szrj       { insert(__list.begin(), __list.end()); }
311*38fd1498Szrj #endif
312*38fd1498Szrj 
313*38fd1498Szrj       iterator
314*38fd1498Szrj #if __cplusplus >= 201103L
315*38fd1498Szrj       insert(const_iterator __pos, const value_type& __x)
316*38fd1498Szrj #else
317*38fd1498Szrj       insert(iterator __pos, const value_type& __x)
318*38fd1498Szrj #endif
319*38fd1498Szrj       {
320*38fd1498Szrj 	size_type size_before = this->size();
321*38fd1498Szrj 	_Base_iterator __res = _Base::insert(__pos.base(), __x);
322*38fd1498Szrj 
323*38fd1498Szrj 	__profcxx_map2umap_insert(this->_M_map2umap_info,
324*38fd1498Szrj 		size_before, _M_hint_used(__pos.base(), __res) ? 0 : 1);
325*38fd1498Szrj 	return iterator(__res, this);
326*38fd1498Szrj       }
327*38fd1498Szrj 
328*38fd1498Szrj #if __cplusplus >= 201103L
329*38fd1498Szrj       template<typename _Pair, typename = typename
330*38fd1498Szrj 	       std::enable_if<std::is_constructible<value_type,
331*38fd1498Szrj 						    _Pair&&>::value>::type>
332*38fd1498Szrj 	iterator
333*38fd1498Szrj 	insert(const_iterator __pos, _Pair&& __x)
334*38fd1498Szrj 	{
335*38fd1498Szrj 	  size_type size_before = this->size();
336*38fd1498Szrj 	  auto __res = _Base::insert(__pos.base(), std::forward<_Pair>(__x));
337*38fd1498Szrj 
338*38fd1498Szrj 	  __profcxx_map2umap_insert(this->_M_map2umap_info,
339*38fd1498Szrj 		size_before, _M_hint_used(__pos.base(), __res) ? 0 : 1);
340*38fd1498Szrj 	  return iterator(__res, this);
341*38fd1498Szrj       }
342*38fd1498Szrj #endif
343*38fd1498Szrj 
344*38fd1498Szrj       template<typename _InputIterator>
345*38fd1498Szrj 	void
346*38fd1498Szrj 	insert(_InputIterator __first, _InputIterator __last)
347*38fd1498Szrj 	{
348*38fd1498Szrj 	  for (; __first != __last; ++__first)
349*38fd1498Szrj 	    insert(*__first);
350*38fd1498Szrj 	}
351*38fd1498Szrj 
352*38fd1498Szrj #if __cplusplus >= 201103L
353*38fd1498Szrj       iterator
354*38fd1498Szrj       erase(const_iterator __pos)
355*38fd1498Szrj       {
356*38fd1498Szrj 	__profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
357*38fd1498Szrj 	return iterator(_Base::erase(__pos.base()), this);
358*38fd1498Szrj       }
359*38fd1498Szrj 
360*38fd1498Szrj       iterator
361*38fd1498Szrj       erase(iterator __pos)
362*38fd1498Szrj       {
363*38fd1498Szrj 	__profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
364*38fd1498Szrj 	return iterator(_Base::erase(__pos.base()), this);
365*38fd1498Szrj       }
366*38fd1498Szrj #else
367*38fd1498Szrj       void
368*38fd1498Szrj       erase(iterator __pos)
369*38fd1498Szrj       {
370*38fd1498Szrj 	__profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
371*38fd1498Szrj 	_Base::erase(__pos.base());
372*38fd1498Szrj       }
373*38fd1498Szrj #endif
374*38fd1498Szrj 
375*38fd1498Szrj       size_type
376*38fd1498Szrj       erase(const key_type& __x)
377*38fd1498Szrj       {
378*38fd1498Szrj 	__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
379*38fd1498Szrj 	__profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
380*38fd1498Szrj 	return _Base::erase(__x);
381*38fd1498Szrj       }
382*38fd1498Szrj 
383*38fd1498Szrj #if __cplusplus >= 201103L
384*38fd1498Szrj       iterator
385*38fd1498Szrj       erase(const_iterator __first, const_iterator __last)
386*38fd1498Szrj       {
387*38fd1498Szrj 	if (__first != __last)
388*38fd1498Szrj 	  {
389*38fd1498Szrj 	    iterator __ret;
390*38fd1498Szrj 	    for (; __first != __last;)
391*38fd1498Szrj 	      __ret = erase(__first++);
392*38fd1498Szrj 	    return __ret;
393*38fd1498Szrj 	  }
394*38fd1498Szrj 	else
395*38fd1498Szrj 	  return iterator(_Base::erase(__first.base(), __last.base()), this);
396*38fd1498Szrj       }
397*38fd1498Szrj #else
398*38fd1498Szrj       void
399*38fd1498Szrj       erase(iterator __first, iterator __last)
400*38fd1498Szrj       {
401*38fd1498Szrj 	for (; __first != __last;)
402*38fd1498Szrj 	  erase(__first++);
403*38fd1498Szrj       }
404*38fd1498Szrj #endif
405*38fd1498Szrj 
406*38fd1498Szrj       void
407*38fd1498Szrj       swap(map& __x)
408*38fd1498Szrj       _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) )
409*38fd1498Szrj       {
410*38fd1498Szrj 	_Base::swap(__x);
411*38fd1498Szrj 	this->_M_swap(__x);
412*38fd1498Szrj       }
413*38fd1498Szrj 
414*38fd1498Szrj       void
415*38fd1498Szrj       clear() _GLIBCXX_NOEXCEPT
416*38fd1498Szrj       {
417*38fd1498Szrj 	this->_M_profile_destruct();
418*38fd1498Szrj 	_Base::clear();
419*38fd1498Szrj 	this->_M_profile_construct();
420*38fd1498Szrj       }
421*38fd1498Szrj 
422*38fd1498Szrj       // 23.3.1.3 map operations:
423*38fd1498Szrj       iterator
424*38fd1498Szrj       find(const key_type& __x)
425*38fd1498Szrj       {
426*38fd1498Szrj 	__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
427*38fd1498Szrj 	return iterator(_Base::find(__x), this);
428*38fd1498Szrj       }
429*38fd1498Szrj 
430*38fd1498Szrj #if __cplusplus > 201103L
431*38fd1498Szrj       template<typename _Kt,
432*38fd1498Szrj 	       typename _Req =
433*38fd1498Szrj 		 typename __has_is_transparent<_Compare, _Kt>::type>
434*38fd1498Szrj 	iterator
435*38fd1498Szrj 	find(const _Kt& __x)
436*38fd1498Szrj 	{
437*38fd1498Szrj 	  __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
438*38fd1498Szrj 	  return { _Base::find(__x), this };
439*38fd1498Szrj 	}
440*38fd1498Szrj #endif
441*38fd1498Szrj 
442*38fd1498Szrj       const_iterator
443*38fd1498Szrj       find(const key_type& __x) const
444*38fd1498Szrj       {
445*38fd1498Szrj 	__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
446*38fd1498Szrj 	return const_iterator(_Base::find(__x), this);
447*38fd1498Szrj       }
448*38fd1498Szrj 
449*38fd1498Szrj #if __cplusplus > 201103L
450*38fd1498Szrj       template<typename _Kt,
451*38fd1498Szrj 	       typename _Req =
452*38fd1498Szrj 		 typename __has_is_transparent<_Compare, _Kt>::type>
453*38fd1498Szrj 	const_iterator
454*38fd1498Szrj 	find(const _Kt& __x) const
455*38fd1498Szrj 	{
456*38fd1498Szrj 	  __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
457*38fd1498Szrj 	  return { _Base::find(__x), this };
458*38fd1498Szrj 	}
459*38fd1498Szrj #endif
460*38fd1498Szrj 
461*38fd1498Szrj       size_type
462*38fd1498Szrj       count(const key_type& __x) const
463*38fd1498Szrj       {
464*38fd1498Szrj 	__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
465*38fd1498Szrj 	return _Base::count(__x);
466*38fd1498Szrj       }
467*38fd1498Szrj 
468*38fd1498Szrj #if __cplusplus > 201103L
469*38fd1498Szrj       template<typename _Kt,
470*38fd1498Szrj 	       typename _Req =
471*38fd1498Szrj 		 typename __has_is_transparent<_Compare, _Kt>::type>
472*38fd1498Szrj 	size_type
473*38fd1498Szrj 	count(const _Kt& __x) const
474*38fd1498Szrj 	{
475*38fd1498Szrj 	  __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
476*38fd1498Szrj 	  return _Base::count(__x);
477*38fd1498Szrj 	}
478*38fd1498Szrj #endif
479*38fd1498Szrj 
480*38fd1498Szrj       iterator
481*38fd1498Szrj       lower_bound(const key_type& __x)
482*38fd1498Szrj       {
483*38fd1498Szrj 	__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
484*38fd1498Szrj 	__profcxx_map2umap_invalidate(this->_M_map2umap_info);
485*38fd1498Szrj 	return iterator(_Base::lower_bound(__x), this);
486*38fd1498Szrj       }
487*38fd1498Szrj 
488*38fd1498Szrj #if __cplusplus > 201103L
489*38fd1498Szrj       template<typename _Kt,
490*38fd1498Szrj 	       typename _Req =
491*38fd1498Szrj 		 typename __has_is_transparent<_Compare, _Kt>::type>
492*38fd1498Szrj 	iterator
493*38fd1498Szrj 	lower_bound(const _Kt& __x)
494*38fd1498Szrj 	{
495*38fd1498Szrj 	  __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
496*38fd1498Szrj 	  __profcxx_map2umap_invalidate(this->_M_map2umap_info);
497*38fd1498Szrj 	  return { _Base::lower_bound(__x), this };
498*38fd1498Szrj 	}
499*38fd1498Szrj #endif
500*38fd1498Szrj 
501*38fd1498Szrj       const_iterator
502*38fd1498Szrj       lower_bound(const key_type& __x) const
503*38fd1498Szrj       {
504*38fd1498Szrj 	__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
505*38fd1498Szrj 	__profcxx_map2umap_invalidate(this->_M_map2umap_info);
506*38fd1498Szrj 	return const_iterator(_Base::lower_bound(__x), this);
507*38fd1498Szrj       }
508*38fd1498Szrj 
509*38fd1498Szrj #if __cplusplus > 201103L
510*38fd1498Szrj       template<typename _Kt,
511*38fd1498Szrj 	       typename _Req =
512*38fd1498Szrj 		 typename __has_is_transparent<_Compare, _Kt>::type>
513*38fd1498Szrj 	const_iterator
514*38fd1498Szrj 	lower_bound(const _Kt& __x) const
515*38fd1498Szrj 	{
516*38fd1498Szrj 	  __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
517*38fd1498Szrj 	  __profcxx_map2umap_invalidate(this->_M_map2umap_info);
518*38fd1498Szrj 	  return { _Base::lower_bound(__x), this };
519*38fd1498Szrj 	}
520*38fd1498Szrj #endif
521*38fd1498Szrj 
522*38fd1498Szrj       iterator
523*38fd1498Szrj       upper_bound(const key_type& __x)
524*38fd1498Szrj       {
525*38fd1498Szrj 	__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
526*38fd1498Szrj 	__profcxx_map2umap_invalidate(this->_M_map2umap_info);
527*38fd1498Szrj 	return iterator(_Base::upper_bound(__x), this);
528*38fd1498Szrj       }
529*38fd1498Szrj 
530*38fd1498Szrj #if __cplusplus > 201103L
531*38fd1498Szrj       template<typename _Kt,
532*38fd1498Szrj 	       typename _Req =
533*38fd1498Szrj 		 typename __has_is_transparent<_Compare, _Kt>::type>
534*38fd1498Szrj 	iterator
535*38fd1498Szrj 	upper_bound(const _Kt& __x)
536*38fd1498Szrj 	{
537*38fd1498Szrj 	  __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
538*38fd1498Szrj 	  __profcxx_map2umap_invalidate(this->_M_map2umap_info);
539*38fd1498Szrj 	  return { _Base::upper_bound(__x), this };
540*38fd1498Szrj 	}
541*38fd1498Szrj #endif
542*38fd1498Szrj 
543*38fd1498Szrj       const_iterator
544*38fd1498Szrj       upper_bound(const key_type& __x) const
545*38fd1498Szrj       {
546*38fd1498Szrj 	__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
547*38fd1498Szrj 	__profcxx_map2umap_invalidate(this->_M_map2umap_info);
548*38fd1498Szrj 	return const_iterator(_Base::upper_bound(__x), this);
549*38fd1498Szrj       }
550*38fd1498Szrj 
551*38fd1498Szrj #if __cplusplus > 201103L
552*38fd1498Szrj       template<typename _Kt,
553*38fd1498Szrj 	       typename _Req =
554*38fd1498Szrj 		 typename __has_is_transparent<_Compare, _Kt>::type>
555*38fd1498Szrj 	const_iterator
556*38fd1498Szrj 	upper_bound(const _Kt& __x) const
557*38fd1498Szrj 	{
558*38fd1498Szrj 	  __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
559*38fd1498Szrj 	  __profcxx_map2umap_invalidate(this->_M_map2umap_info);
560*38fd1498Szrj 	  return { _Base::upper_bound(__x), this };
561*38fd1498Szrj 	}
562*38fd1498Szrj #endif
563*38fd1498Szrj 
564*38fd1498Szrj       std::pair<iterator,iterator>
565*38fd1498Szrj       equal_range(const key_type& __x)
566*38fd1498Szrj       {
567*38fd1498Szrj 	__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
568*38fd1498Szrj 	std::pair<_Base_iterator, _Base_iterator> __base_ret
569*38fd1498Szrj 	  = _Base::equal_range(__x);
570*38fd1498Szrj 	return std::make_pair(iterator(__base_ret.first, this),
571*38fd1498Szrj 			      iterator(__base_ret.second, this));
572*38fd1498Szrj       }
573*38fd1498Szrj 
574*38fd1498Szrj #if __cplusplus > 201103L
575*38fd1498Szrj       template<typename _Kt,
576*38fd1498Szrj 	       typename _Req =
577*38fd1498Szrj 		 typename __has_is_transparent<_Compare, _Kt>::type>
578*38fd1498Szrj 	std::pair<iterator, iterator>
579*38fd1498Szrj 	equal_range(const _Kt& __x)
580*38fd1498Szrj 	{
581*38fd1498Szrj 	  __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
582*38fd1498Szrj 	  auto __res = _Base::equal_range(__x);
583*38fd1498Szrj 	  return { { __res.first, this }, { __res.second, this } };
584*38fd1498Szrj 	}
585*38fd1498Szrj #endif
586*38fd1498Szrj 
587*38fd1498Szrj       std::pair<const_iterator,const_iterator>
588*38fd1498Szrj       equal_range(const key_type& __x) const
589*38fd1498Szrj       {
590*38fd1498Szrj 	__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
591*38fd1498Szrj 	std::pair<_Base_const_iterator, _Base_const_iterator> __base_ret
592*38fd1498Szrj 	  = _Base::equal_range(__x);
593*38fd1498Szrj 	return std::make_pair(const_iterator(__base_ret.first, this),
594*38fd1498Szrj 			      const_iterator(__base_ret.second, this));
595*38fd1498Szrj       }
596*38fd1498Szrj 
597*38fd1498Szrj #if __cplusplus > 201103L
598*38fd1498Szrj       template<typename _Kt,
599*38fd1498Szrj 	       typename _Req =
600*38fd1498Szrj 		 typename __has_is_transparent<_Compare, _Kt>::type>
601*38fd1498Szrj 	std::pair<const_iterator, const_iterator>
602*38fd1498Szrj 	equal_range(const _Kt& __x) const
603*38fd1498Szrj 	{
604*38fd1498Szrj 	  __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
605*38fd1498Szrj 	  auto __res = _Base::equal_range(__x);
606*38fd1498Szrj 	  return { { __res.first, this }, { __res.second, this } };
607*38fd1498Szrj 	}
608*38fd1498Szrj #endif
609*38fd1498Szrj 
610*38fd1498Szrj       _Base&
611*38fd1498Szrj       _M_base() _GLIBCXX_NOEXCEPT	{ return *this; }
612*38fd1498Szrj 
613*38fd1498Szrj       const _Base&
614*38fd1498Szrj       _M_base() const _GLIBCXX_NOEXCEPT	{ return *this; }
615*38fd1498Szrj 
616*38fd1498Szrj     private:
617*38fd1498Szrj       /** If hint is used we consider that the map and unordered_map
618*38fd1498Szrj        * operations have equivalent insertion cost so we do not update metrics
619*38fd1498Szrj        * about it.
620*38fd1498Szrj        * Note that to find out if hint has been used is libstdc++
621*38fd1498Szrj        * implementation dependent.
622*38fd1498Szrj        */
623*38fd1498Szrj       bool
624*38fd1498Szrj       _M_hint_used(_Base_const_iterator __hint, _Base_iterator __res)
625*38fd1498Szrj       {
626*38fd1498Szrj 	return (__hint == __res
627*38fd1498Szrj 		|| (__hint == _M_base().end() && ++__res == _M_base().end())
628*38fd1498Szrj 		|| (__hint != _M_base().end() && (++__hint == __res
629*38fd1498Szrj 						  || ++__res == --__hint)));
630*38fd1498Szrj       }
631*38fd1498Szrj 
632*38fd1498Szrj 
633*38fd1498Szrj       template<typename _K1, typename _T1, typename _C1, typename _A1>
634*38fd1498Szrj         friend bool
635*38fd1498Szrj         operator==(const map<_K1, _T1, _C1, _A1>&,
636*38fd1498Szrj 		   const map<_K1, _T1, _C1, _A1>&);
637*38fd1498Szrj 
638*38fd1498Szrj       template<typename _K1, typename _T1, typename _C1, typename _A1>
639*38fd1498Szrj         friend bool
640*38fd1498Szrj         operator<(const map<_K1, _T1, _C1, _A1>&,
641*38fd1498Szrj 		  const map<_K1, _T1, _C1, _A1>&);
642*38fd1498Szrj     };
643*38fd1498Szrj 
644*38fd1498Szrj   template<typename _Key, typename _Tp,
645*38fd1498Szrj 	   typename _Compare, typename _Allocator>
646*38fd1498Szrj     inline bool
647*38fd1498Szrj     operator==(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
648*38fd1498Szrj 	       const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
649*38fd1498Szrj     {
650*38fd1498Szrj       __profcxx_map2umap_invalidate(__lhs._M_map2umap_info);
651*38fd1498Szrj       __profcxx_map2umap_invalidate(__rhs._M_map2umap_info);
652*38fd1498Szrj       return __lhs._M_base() == __rhs._M_base();
653*38fd1498Szrj     }
654*38fd1498Szrj 
655*38fd1498Szrj   template<typename _Key, typename _Tp,
656*38fd1498Szrj 	   typename _Compare, typename _Allocator>
657*38fd1498Szrj     inline bool
658*38fd1498Szrj     operator<(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
659*38fd1498Szrj 	      const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
660*38fd1498Szrj     {
661*38fd1498Szrj       __profcxx_map2umap_invalidate(__lhs._M_map2umap_info);
662*38fd1498Szrj       __profcxx_map2umap_invalidate(__rhs._M_map2umap_info);
663*38fd1498Szrj       return __lhs._M_base() < __rhs._M_base();
664*38fd1498Szrj     }
665*38fd1498Szrj 
666*38fd1498Szrj   template<typename _Key, typename _Tp,
667*38fd1498Szrj 	   typename _Compare, typename _Allocator>
668*38fd1498Szrj     inline bool
669*38fd1498Szrj     operator!=(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
670*38fd1498Szrj 	       const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
671*38fd1498Szrj     { return !(__lhs == __rhs); }
672*38fd1498Szrj 
673*38fd1498Szrj   template<typename _Key, typename _Tp,
674*38fd1498Szrj 	   typename _Compare, typename _Allocator>
675*38fd1498Szrj     inline bool
676*38fd1498Szrj     operator<=(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
677*38fd1498Szrj 	       const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
678*38fd1498Szrj     { return !(__rhs < __lhs); }
679*38fd1498Szrj 
680*38fd1498Szrj   template<typename _Key, typename _Tp,
681*38fd1498Szrj 	   typename _Compare, typename _Allocator>
682*38fd1498Szrj     inline bool
683*38fd1498Szrj     operator>=(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
684*38fd1498Szrj 	       const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
685*38fd1498Szrj     { return !(__lhs < __rhs); }
686*38fd1498Szrj 
687*38fd1498Szrj   template<typename _Key, typename _Tp,
688*38fd1498Szrj 	   typename _Compare, typename _Allocator>
689*38fd1498Szrj     inline bool
690*38fd1498Szrj     operator>(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
691*38fd1498Szrj 	      const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
692*38fd1498Szrj     { return __rhs < __lhs; }
693*38fd1498Szrj 
694*38fd1498Szrj   template<typename _Key, typename _Tp,
695*38fd1498Szrj 	   typename _Compare, typename _Allocator>
696*38fd1498Szrj     inline void
697*38fd1498Szrj     swap(map<_Key, _Tp, _Compare, _Allocator>& __lhs,
698*38fd1498Szrj 	 map<_Key, _Tp, _Compare, _Allocator>& __rhs)
699*38fd1498Szrj     _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
700*38fd1498Szrj     { __lhs.swap(__rhs); }
701*38fd1498Szrj 
702*38fd1498Szrj } // namespace __profile
703*38fd1498Szrj } // namespace std
704*38fd1498Szrj 
705*38fd1498Szrj #endif
706