xref: /dflybsd-src/contrib/gcc-8.0/libstdc++-v3/include/profile/multimap.h (revision 38fd149817dfbff97799f62fcb70be98c4e32523)
1*38fd1498Szrj // Profiling multimap 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/multimap.h
26*38fd1498Szrj  *  This file is a GNU profile extension to the Standard C++ Library.
27*38fd1498Szrj  */
28*38fd1498Szrj 
29*38fd1498Szrj #ifndef _GLIBCXX_PROFILE_MULTIMAP_H
30*38fd1498Szrj #define _GLIBCXX_PROFILE_MULTIMAP_H 1
31*38fd1498Szrj 
32*38fd1498Szrj #include <profile/base.h>
33*38fd1498Szrj #include <profile/ordered_base.h>
34*38fd1498Szrj 
_GLIBCXX_VISIBILITY(default)35*38fd1498Szrj namespace std _GLIBCXX_VISIBILITY(default)
36*38fd1498Szrj {
37*38fd1498Szrj namespace __profile
38*38fd1498Szrj {
39*38fd1498Szrj   /// Class std::multimap wrapper with performance instrumentation.
40*38fd1498Szrj   template<typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
41*38fd1498Szrj 	   typename _Allocator = std::allocator<std::pair<const _Key, _Tp> > >
42*38fd1498Szrj     class multimap
43*38fd1498Szrj     : public _GLIBCXX_STD_C::multimap<_Key, _Tp, _Compare, _Allocator>,
44*38fd1498Szrj       public _Ordered_profile<map<_Key, _Tp, _Compare, _Allocator> >
45*38fd1498Szrj     {
46*38fd1498Szrj       typedef _GLIBCXX_STD_C::multimap<_Key, _Tp, _Compare, _Allocator> _Base;
47*38fd1498Szrj 
48*38fd1498Szrj       typedef typename _Base::iterator			_Base_iterator;
49*38fd1498Szrj       typedef typename _Base::const_iterator		_Base_const_iterator;
50*38fd1498Szrj 
51*38fd1498Szrj     public:
52*38fd1498Szrj       // types:
53*38fd1498Szrj       typedef _Key					key_type;
54*38fd1498Szrj       typedef _Tp					mapped_type;
55*38fd1498Szrj       typedef std::pair<const _Key, _Tp>		value_type;
56*38fd1498Szrj       typedef _Compare					key_compare;
57*38fd1498Szrj       typedef typename _Base::reference			reference;
58*38fd1498Szrj       typedef typename _Base::const_reference		const_reference;
59*38fd1498Szrj 
60*38fd1498Szrj       typedef __iterator_tracker<_Base_iterator,
61*38fd1498Szrj 				 multimap>		iterator;
62*38fd1498Szrj       typedef __iterator_tracker<_Base_const_iterator,
63*38fd1498Szrj 				 multimap>		const_iterator;
64*38fd1498Szrj       typedef std::reverse_iterator<iterator>		reverse_iterator;
65*38fd1498Szrj       typedef std::reverse_iterator<const_iterator>	const_reverse_iterator;
66*38fd1498Szrj 
67*38fd1498Szrj       typedef typename _Base::size_type			size_type;
68*38fd1498Szrj       typedef typename _Base::difference_type		difference_type;
69*38fd1498Szrj 
70*38fd1498Szrj       // 23.3.1.1 construct/copy/destroy:
71*38fd1498Szrj 
72*38fd1498Szrj #if __cplusplus < 201103L
73*38fd1498Szrj       multimap()
74*38fd1498Szrj       : _Base() { }
75*38fd1498Szrj       multimap(const multimap& __x)
76*38fd1498Szrj       : _Base(__x) { }
77*38fd1498Szrj       ~multimap() { }
78*38fd1498Szrj #else
79*38fd1498Szrj       multimap() = default;
80*38fd1498Szrj       multimap(const multimap&) = default;
81*38fd1498Szrj       multimap(multimap&&) = default;
82*38fd1498Szrj       ~multimap() = default;
83*38fd1498Szrj #endif
84*38fd1498Szrj 
85*38fd1498Szrj       explicit multimap(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 	multimap(_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 #if __cplusplus >= 201103L
101*38fd1498Szrj       multimap(initializer_list<value_type> __l,
102*38fd1498Szrj 	       const _Compare& __c = _Compare(),
103*38fd1498Szrj 	       const _Allocator& __a = _Allocator())
104*38fd1498Szrj       : _Base(__l, __c, __a) { }
105*38fd1498Szrj 
106*38fd1498Szrj       explicit
107*38fd1498Szrj       multimap(const _Allocator& __a)
108*38fd1498Szrj       : _Base(__a) { }
109*38fd1498Szrj 
110*38fd1498Szrj       multimap(const multimap& __x, const _Allocator& __a)
111*38fd1498Szrj       : _Base(__x, __a) { }
112*38fd1498Szrj 
113*38fd1498Szrj       multimap(multimap&& __x, const _Allocator& __a)
114*38fd1498Szrj       noexcept( noexcept(_Base(std::move(__x), __a)) )
115*38fd1498Szrj       : _Base(std::move(__x), __a) { }
116*38fd1498Szrj 
117*38fd1498Szrj       multimap(initializer_list<value_type> __l, const _Allocator& __a)
118*38fd1498Szrj       : _Base(__l, __a) { }
119*38fd1498Szrj 
120*38fd1498Szrj       template<typename _InputIterator>
121*38fd1498Szrj 	multimap(_InputIterator __first, _InputIterator __last,
122*38fd1498Szrj 		 const _Allocator& __a)
123*38fd1498Szrj 	: _Base(__first, __last, __a) { }
124*38fd1498Szrj #endif
125*38fd1498Szrj 
126*38fd1498Szrj       multimap(const _Base& __x)
127*38fd1498Szrj       : _Base(__x) { }
128*38fd1498Szrj 
129*38fd1498Szrj #if __cplusplus < 201103L
130*38fd1498Szrj       multimap&
131*38fd1498Szrj       operator=(const multimap& __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       multimap&
140*38fd1498Szrj       operator=(const multimap&) = default;
141*38fd1498Szrj 
142*38fd1498Szrj       multimap&
143*38fd1498Szrj       operator=(multimap&&) = default;
144*38fd1498Szrj 
145*38fd1498Szrj       multimap&
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       // modifiers:
227*38fd1498Szrj #if __cplusplus >= 201103L
228*38fd1498Szrj       template<typename... _Args>
229*38fd1498Szrj 	iterator
230*38fd1498Szrj 	emplace(_Args&&... __args)
231*38fd1498Szrj 	{
232*38fd1498Szrj 	  __profcxx_map2umap_insert(this->_M_map2umap_info, this->size(), 1);
233*38fd1498Szrj 	  return iterator(_Base::emplace(std::forward<_Args>(__args)...), this);
234*38fd1498Szrj 	}
235*38fd1498Szrj 
236*38fd1498Szrj       template<typename... _Args>
237*38fd1498Szrj 	iterator
238*38fd1498Szrj 	emplace_hint(const_iterator __pos, _Args&&... __args)
239*38fd1498Szrj 	{
240*38fd1498Szrj 	  auto size_before = this->size();
241*38fd1498Szrj 	  auto __res
242*38fd1498Szrj 	    = _Base::emplace_hint(__pos.base(), std::forward<_Args>(__args)...);
243*38fd1498Szrj 	  __profcxx_map2umap_insert(this->_M_map2umap_info,
244*38fd1498Szrj 		size_before, _M_hint_used(__pos.base(), __res) ? 0 : 1);
245*38fd1498Szrj 	  return iterator(__res, this);
246*38fd1498Szrj 	}
247*38fd1498Szrj #endif
248*38fd1498Szrj 
249*38fd1498Szrj       iterator
250*38fd1498Szrj       insert(const value_type& __x)
251*38fd1498Szrj       {
252*38fd1498Szrj 	__profcxx_map2umap_insert(this->_M_map2umap_info, this->size(), 1);
253*38fd1498Szrj 	return iterator(_Base::insert(__x), this);
254*38fd1498Szrj       }
255*38fd1498Szrj 
256*38fd1498Szrj #if __cplusplus >= 201103L
257*38fd1498Szrj       template<typename _Pair, typename = typename
258*38fd1498Szrj 	       std::enable_if<std::is_constructible<value_type,
259*38fd1498Szrj 						    _Pair&&>::value>::type>
260*38fd1498Szrj 	iterator
261*38fd1498Szrj 	insert(_Pair&& __x)
262*38fd1498Szrj 	{
263*38fd1498Szrj 	  __profcxx_map2umap_insert(this->_M_map2umap_info, this->size(), 1);
264*38fd1498Szrj 	  return iterator(_Base::insert(std::forward<_Pair>(__x)), this);
265*38fd1498Szrj 	}
266*38fd1498Szrj #endif
267*38fd1498Szrj 
268*38fd1498Szrj #if __cplusplus >= 201103L
269*38fd1498Szrj       void
270*38fd1498Szrj       insert(std::initializer_list<value_type> __list)
271*38fd1498Szrj       { insert(__list.begin(), __list.end()); }
272*38fd1498Szrj #endif
273*38fd1498Szrj 
274*38fd1498Szrj       iterator
275*38fd1498Szrj #if __cplusplus >= 201103L
276*38fd1498Szrj       insert(const_iterator __pos, const value_type& __x)
277*38fd1498Szrj #else
278*38fd1498Szrj       insert(iterator __pos, const value_type& __x)
279*38fd1498Szrj #endif
280*38fd1498Szrj       {
281*38fd1498Szrj 	size_type size_before = this->size();
282*38fd1498Szrj 	_Base_iterator __res = _Base::insert(__pos.base(), __x);
283*38fd1498Szrj 	__profcxx_map2umap_insert(this->_M_map2umap_info,
284*38fd1498Szrj 		size_before, _M_hint_used(__pos.base(), __res) ? 0 : 1);
285*38fd1498Szrj 	return iterator(__res, this);
286*38fd1498Szrj       }
287*38fd1498Szrj 
288*38fd1498Szrj #if __cplusplus >= 201103L
289*38fd1498Szrj       template<typename _Pair, typename = typename
290*38fd1498Szrj 	       std::enable_if<std::is_constructible<value_type,
291*38fd1498Szrj 						    _Pair&&>::value>::type>
292*38fd1498Szrj 	iterator
293*38fd1498Szrj 	insert(const_iterator __pos, _Pair&& __x)
294*38fd1498Szrj 	{
295*38fd1498Szrj 	  size_type size_before = this->size();
296*38fd1498Szrj 	  auto __res = _Base::insert(__pos.base(), std::forward<_Pair>(__x));
297*38fd1498Szrj 	  __profcxx_map2umap_insert(this->_M_map2umap_info,
298*38fd1498Szrj 		size_before, _M_hint_used(__pos.base(), __res) ? 0 : 1);
299*38fd1498Szrj 	  return iterator(__res, this);
300*38fd1498Szrj 	}
301*38fd1498Szrj #endif
302*38fd1498Szrj 
303*38fd1498Szrj       template<typename _InputIterator>
304*38fd1498Szrj 	void
305*38fd1498Szrj 	insert(_InputIterator __first, _InputIterator __last)
306*38fd1498Szrj 	{
307*38fd1498Szrj 	  for (; __first != __last; ++__first)
308*38fd1498Szrj 	    insert(*__first);
309*38fd1498Szrj 	}
310*38fd1498Szrj 
311*38fd1498Szrj #if __cplusplus >= 201103L
312*38fd1498Szrj       iterator
313*38fd1498Szrj       erase(const_iterator __pos)
314*38fd1498Szrj       {
315*38fd1498Szrj 	__profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
316*38fd1498Szrj 	return iterator(_Base::erase(__pos.base()), this);
317*38fd1498Szrj       }
318*38fd1498Szrj 
319*38fd1498Szrj       iterator
320*38fd1498Szrj       erase(iterator __pos)
321*38fd1498Szrj       {
322*38fd1498Szrj 	__profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
323*38fd1498Szrj 	return iterator(_Base::erase(__pos.base()), this);
324*38fd1498Szrj       }
325*38fd1498Szrj #else
326*38fd1498Szrj       void
327*38fd1498Szrj       erase(iterator __pos)
328*38fd1498Szrj       {
329*38fd1498Szrj 	__profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
330*38fd1498Szrj 	_Base::erase(__pos.base());
331*38fd1498Szrj       }
332*38fd1498Szrj #endif
333*38fd1498Szrj 
334*38fd1498Szrj       size_type
335*38fd1498Szrj       erase(const key_type& __x)
336*38fd1498Szrj       {
337*38fd1498Szrj 	__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
338*38fd1498Szrj 	__profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
339*38fd1498Szrj 	return _Base::erase(__x);
340*38fd1498Szrj       }
341*38fd1498Szrj 
342*38fd1498Szrj #if __cplusplus >= 201103L
343*38fd1498Szrj       iterator
344*38fd1498Szrj       erase(const_iterator __first, const_iterator __last)
345*38fd1498Szrj       {
346*38fd1498Szrj 	if (__first != __last)
347*38fd1498Szrj 	  {
348*38fd1498Szrj 	    iterator __ret;
349*38fd1498Szrj 	    for (; __first != __last;)
350*38fd1498Szrj 	      __ret = erase(__first++);
351*38fd1498Szrj 	    return __ret;
352*38fd1498Szrj 	  }
353*38fd1498Szrj 	else
354*38fd1498Szrj 	  return iterator(_Base::erase(__first.base(), __last.base()), this);
355*38fd1498Szrj       }
356*38fd1498Szrj #else
357*38fd1498Szrj       void
358*38fd1498Szrj       erase(iterator __first, iterator __last)
359*38fd1498Szrj       {
360*38fd1498Szrj 	for (; __first != __last;)
361*38fd1498Szrj 	  erase(__first++);
362*38fd1498Szrj       }
363*38fd1498Szrj #endif
364*38fd1498Szrj 
365*38fd1498Szrj       void
366*38fd1498Szrj       swap(multimap& __x)
367*38fd1498Szrj       _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) )
368*38fd1498Szrj       {
369*38fd1498Szrj 	std::swap(this->_M_map2umap_info, __x._M_map2umap_info);
370*38fd1498Szrj 	_Base::swap(__x);
371*38fd1498Szrj       }
372*38fd1498Szrj 
373*38fd1498Szrj       void
374*38fd1498Szrj       clear() _GLIBCXX_NOEXCEPT
375*38fd1498Szrj       {
376*38fd1498Szrj 	this->_M_profile_destruct();
377*38fd1498Szrj 	_Base::clear();
378*38fd1498Szrj 	this->_M_profile_construct();
379*38fd1498Szrj       }
380*38fd1498Szrj 
381*38fd1498Szrj       // 23.3.1.3 multimap operations:
382*38fd1498Szrj       iterator
383*38fd1498Szrj       find(const key_type& __x)
384*38fd1498Szrj       {
385*38fd1498Szrj 	__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
386*38fd1498Szrj 	return iterator(_Base::find(__x), this);
387*38fd1498Szrj       }
388*38fd1498Szrj 
389*38fd1498Szrj #if __cplusplus > 201103L
390*38fd1498Szrj       template<typename _Kt,
391*38fd1498Szrj 	       typename _Req =
392*38fd1498Szrj 		 typename __has_is_transparent<_Compare, _Kt>::type>
393*38fd1498Szrj 	iterator
394*38fd1498Szrj 	find(const _Kt& __x)
395*38fd1498Szrj 	{
396*38fd1498Szrj 	  __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
397*38fd1498Szrj 	  return { _Base::find(__x), this };
398*38fd1498Szrj 	}
399*38fd1498Szrj #endif
400*38fd1498Szrj 
401*38fd1498Szrj       const_iterator
402*38fd1498Szrj       find(const key_type& __x) const
403*38fd1498Szrj       {
404*38fd1498Szrj 	__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
405*38fd1498Szrj 	return const_iterator(_Base::find(__x), this);
406*38fd1498Szrj       }
407*38fd1498Szrj 
408*38fd1498Szrj #if __cplusplus > 201103L
409*38fd1498Szrj       template<typename _Kt,
410*38fd1498Szrj 	       typename _Req =
411*38fd1498Szrj 		 typename __has_is_transparent<_Compare, _Kt>::type>
412*38fd1498Szrj 	const_iterator
413*38fd1498Szrj 	find(const _Kt& __x) const
414*38fd1498Szrj 	{
415*38fd1498Szrj 	  __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
416*38fd1498Szrj 	  return { _Base::find(__x), this };
417*38fd1498Szrj 	}
418*38fd1498Szrj #endif
419*38fd1498Szrj 
420*38fd1498Szrj       size_type
421*38fd1498Szrj       count(const key_type& __x) const
422*38fd1498Szrj       {
423*38fd1498Szrj 	__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
424*38fd1498Szrj 	return _Base::count(__x);
425*38fd1498Szrj       }
426*38fd1498Szrj 
427*38fd1498Szrj #if __cplusplus > 201103L
428*38fd1498Szrj       template<typename _Kt,
429*38fd1498Szrj 	       typename _Req =
430*38fd1498Szrj 		 typename __has_is_transparent<_Compare, _Kt>::type>
431*38fd1498Szrj 	size_type
432*38fd1498Szrj 	count(const _Kt& __x) const
433*38fd1498Szrj 	{
434*38fd1498Szrj 	  __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
435*38fd1498Szrj 	  return _Base::count(__x);
436*38fd1498Szrj 	}
437*38fd1498Szrj #endif
438*38fd1498Szrj 
439*38fd1498Szrj       iterator
440*38fd1498Szrj       lower_bound(const key_type& __x)
441*38fd1498Szrj       {
442*38fd1498Szrj 	__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
443*38fd1498Szrj 	__profcxx_map2umap_invalidate(this->_M_map2umap_info);
444*38fd1498Szrj 	return iterator(_Base::lower_bound(__x), this);
445*38fd1498Szrj       }
446*38fd1498Szrj 
447*38fd1498Szrj #if __cplusplus > 201103L
448*38fd1498Szrj       template<typename _Kt,
449*38fd1498Szrj 	       typename _Req =
450*38fd1498Szrj 		 typename __has_is_transparent<_Compare, _Kt>::type>
451*38fd1498Szrj 	iterator
452*38fd1498Szrj 	lower_bound(const _Kt& __x)
453*38fd1498Szrj 	{
454*38fd1498Szrj 	  __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
455*38fd1498Szrj 	  __profcxx_map2umap_invalidate(this->_M_map2umap_info);
456*38fd1498Szrj 	  return { _Base::lower_bound(__x), this };
457*38fd1498Szrj 	}
458*38fd1498Szrj #endif
459*38fd1498Szrj 
460*38fd1498Szrj       const_iterator
461*38fd1498Szrj       lower_bound(const key_type& __x) const
462*38fd1498Szrj       {
463*38fd1498Szrj 	__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
464*38fd1498Szrj 	__profcxx_map2umap_invalidate(this->_M_map2umap_info);
465*38fd1498Szrj 	return const_iterator(_Base::lower_bound(__x), this);
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 	const_iterator
473*38fd1498Szrj 	lower_bound(const _Kt& __x) const
474*38fd1498Szrj 	{
475*38fd1498Szrj 	  __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
476*38fd1498Szrj 	  __profcxx_map2umap_invalidate(this->_M_map2umap_info);
477*38fd1498Szrj 	  return { _Base::lower_bound(__x), this };
478*38fd1498Szrj 	}
479*38fd1498Szrj #endif
480*38fd1498Szrj 
481*38fd1498Szrj       iterator
482*38fd1498Szrj       upper_bound(const key_type& __x)
483*38fd1498Szrj       {
484*38fd1498Szrj 	__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
485*38fd1498Szrj 	__profcxx_map2umap_invalidate(this->_M_map2umap_info);
486*38fd1498Szrj 	return iterator(_Base::upper_bound(__x), this);
487*38fd1498Szrj       }
488*38fd1498Szrj 
489*38fd1498Szrj #if __cplusplus > 201103L
490*38fd1498Szrj       template<typename _Kt,
491*38fd1498Szrj 	       typename _Req =
492*38fd1498Szrj 		 typename __has_is_transparent<_Compare, _Kt>::type>
493*38fd1498Szrj 	iterator
494*38fd1498Szrj 	upper_bound(const _Kt& __x)
495*38fd1498Szrj 	{
496*38fd1498Szrj 	  __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
497*38fd1498Szrj 	  __profcxx_map2umap_invalidate(this->_M_map2umap_info);
498*38fd1498Szrj 	  return { _Base::upper_bound(__x), this };
499*38fd1498Szrj 	}
500*38fd1498Szrj #endif
501*38fd1498Szrj 
502*38fd1498Szrj       const_iterator
503*38fd1498Szrj       upper_bound(const key_type& __x) const
504*38fd1498Szrj       {
505*38fd1498Szrj 	__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
506*38fd1498Szrj 	__profcxx_map2umap_invalidate(this->_M_map2umap_info);
507*38fd1498Szrj 	return const_iterator(_Base::upper_bound(__x), this);
508*38fd1498Szrj       }
509*38fd1498Szrj 
510*38fd1498Szrj #if __cplusplus > 201103L
511*38fd1498Szrj       template<typename _Kt,
512*38fd1498Szrj 	       typename _Req =
513*38fd1498Szrj 		 typename __has_is_transparent<_Compare, _Kt>::type>
514*38fd1498Szrj 	const_iterator
515*38fd1498Szrj 	upper_bound(const _Kt& __x) const
516*38fd1498Szrj 	{
517*38fd1498Szrj 	  __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
518*38fd1498Szrj 	  __profcxx_map2umap_invalidate(this->_M_map2umap_info);
519*38fd1498Szrj 	  return { _Base::upper_bound(__x), this };
520*38fd1498Szrj 	}
521*38fd1498Szrj #endif
522*38fd1498Szrj 
523*38fd1498Szrj       std::pair<iterator,iterator>
524*38fd1498Szrj       equal_range(const key_type& __x)
525*38fd1498Szrj       {
526*38fd1498Szrj 	__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
527*38fd1498Szrj 	std::pair<_Base_iterator, _Base_iterator> __base_ret
528*38fd1498Szrj 	  = _Base::equal_range(__x);
529*38fd1498Szrj 	return std::make_pair(iterator(__base_ret.first, this),
530*38fd1498Szrj 			      iterator(__base_ret.second, this));
531*38fd1498Szrj       }
532*38fd1498Szrj 
533*38fd1498Szrj #if __cplusplus > 201103L
534*38fd1498Szrj       template<typename _Kt,
535*38fd1498Szrj 	       typename _Req =
536*38fd1498Szrj 		 typename __has_is_transparent<_Compare, _Kt>::type>
537*38fd1498Szrj 	std::pair<iterator, iterator>
538*38fd1498Szrj 	equal_range(const _Kt& __x)
539*38fd1498Szrj 	{
540*38fd1498Szrj 	  __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
541*38fd1498Szrj 	  auto __res = _Base::equal_range(__x);
542*38fd1498Szrj 	  return { { __res.first, this }, { __res.second, this } };
543*38fd1498Szrj 	}
544*38fd1498Szrj #endif
545*38fd1498Szrj 
546*38fd1498Szrj       std::pair<const_iterator,const_iterator>
547*38fd1498Szrj       equal_range(const key_type& __x) const
548*38fd1498Szrj       {
549*38fd1498Szrj 	__profcxx_map2umap_find(this->_M_map2umap_info, this->size());
550*38fd1498Szrj 	std::pair<_Base_const_iterator, _Base_const_iterator> __base_ret
551*38fd1498Szrj 	  = _Base::equal_range(__x);
552*38fd1498Szrj 	return std::make_pair(const_iterator(__base_ret.first, this),
553*38fd1498Szrj 			      const_iterator(__base_ret.second, this));
554*38fd1498Szrj       }
555*38fd1498Szrj 
556*38fd1498Szrj #if __cplusplus > 201103L
557*38fd1498Szrj       template<typename _Kt,
558*38fd1498Szrj 	       typename _Req =
559*38fd1498Szrj 		 typename __has_is_transparent<_Compare, _Kt>::type>
560*38fd1498Szrj 	std::pair<const_iterator, const_iterator>
561*38fd1498Szrj 	equal_range(const _Kt& __x) const
562*38fd1498Szrj 	{
563*38fd1498Szrj 	  __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
564*38fd1498Szrj 	  auto __res = _Base::equal_range(__x);
565*38fd1498Szrj 	  return { { __res.first, this }, { __res.second, this } };
566*38fd1498Szrj 	}
567*38fd1498Szrj #endif
568*38fd1498Szrj 
569*38fd1498Szrj       _Base&
570*38fd1498Szrj       _M_base() _GLIBCXX_NOEXCEPT	{ return *this; }
571*38fd1498Szrj 
572*38fd1498Szrj       const _Base&
573*38fd1498Szrj       _M_base() const _GLIBCXX_NOEXCEPT	{ return *this; }
574*38fd1498Szrj 
575*38fd1498Szrj     private:
576*38fd1498Szrj       /** If hint is used we consider that the map and unordered_map
577*38fd1498Szrj        * operations have equivalent insertion cost so we do not update metrics
578*38fd1498Szrj        * about it.
579*38fd1498Szrj        * Note that to find out if hint has been used is libstdc++
580*38fd1498Szrj        * implementation dependent.
581*38fd1498Szrj        */
582*38fd1498Szrj       bool
583*38fd1498Szrj       _M_hint_used(_Base_const_iterator __hint, _Base_iterator __res)
584*38fd1498Szrj       {
585*38fd1498Szrj 	return (__hint == __res
586*38fd1498Szrj 		|| (__hint == _M_base().end() && ++__res == _M_base().end())
587*38fd1498Szrj 		|| (__hint != _M_base().end() && (++__hint == __res
588*38fd1498Szrj 						  || ++__res == --__hint)));
589*38fd1498Szrj       }
590*38fd1498Szrj 
591*38fd1498Szrj       template<typename _K1, typename _T1, typename _C1, typename _A1>
592*38fd1498Szrj         friend bool
593*38fd1498Szrj         operator==(const multimap<_K1, _T1, _C1, _A1>&,
594*38fd1498Szrj 		   const multimap<_K1, _T1, _C1, _A1>&);
595*38fd1498Szrj 
596*38fd1498Szrj       template<typename _K1, typename _T1, typename _C1, typename _A1>
597*38fd1498Szrj         friend bool
598*38fd1498Szrj         operator<(const multimap<_K1, _T1, _C1, _A1>&,
599*38fd1498Szrj 		  const multimap<_K1, _T1, _C1, _A1>&);
600*38fd1498Szrj     };
601*38fd1498Szrj 
602*38fd1498Szrj   template<typename _Key, typename _Tp,
603*38fd1498Szrj 	   typename _Compare, typename _Allocator>
604*38fd1498Szrj     inline bool
605*38fd1498Szrj     operator==(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
606*38fd1498Szrj 	       const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
607*38fd1498Szrj     {
608*38fd1498Szrj       __profcxx_map2umap_invalidate(__lhs._M_map2umap_info);
609*38fd1498Szrj       __profcxx_map2umap_invalidate(__rhs._M_map2umap_info);
610*38fd1498Szrj       return __lhs._M_base() == __rhs._M_base();
611*38fd1498Szrj     }
612*38fd1498Szrj 
613*38fd1498Szrj   template<typename _Key, typename _Tp,
614*38fd1498Szrj 	   typename _Compare, typename _Allocator>
615*38fd1498Szrj     inline bool
616*38fd1498Szrj     operator<(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
617*38fd1498Szrj 	      const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
618*38fd1498Szrj     {
619*38fd1498Szrj       __profcxx_map2umap_invalidate(__lhs._M_map2umap_info);
620*38fd1498Szrj       __profcxx_map2umap_invalidate(__rhs._M_map2umap_info);
621*38fd1498Szrj       return __lhs._M_base() < __rhs._M_base();
622*38fd1498Szrj     }
623*38fd1498Szrj 
624*38fd1498Szrj   template<typename _Key, typename _Tp,
625*38fd1498Szrj 	   typename _Compare, typename _Allocator>
626*38fd1498Szrj     inline bool
627*38fd1498Szrj     operator!=(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
628*38fd1498Szrj 	       const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
629*38fd1498Szrj     { return !(__lhs == __rhs); }
630*38fd1498Szrj 
631*38fd1498Szrj   template<typename _Key, typename _Tp,
632*38fd1498Szrj 	   typename _Compare, typename _Allocator>
633*38fd1498Szrj     inline bool
634*38fd1498Szrj     operator<=(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
635*38fd1498Szrj 	       const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
636*38fd1498Szrj     { return !(__rhs < __lhs); }
637*38fd1498Szrj 
638*38fd1498Szrj   template<typename _Key, typename _Tp,
639*38fd1498Szrj 	   typename _Compare, typename _Allocator>
640*38fd1498Szrj     inline bool
641*38fd1498Szrj     operator>=(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
642*38fd1498Szrj 	       const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
643*38fd1498Szrj     { return !(__lhs < __rhs); }
644*38fd1498Szrj 
645*38fd1498Szrj   template<typename _Key, typename _Tp,
646*38fd1498Szrj 	   typename _Compare, typename _Allocator>
647*38fd1498Szrj     inline bool
648*38fd1498Szrj     operator>(const multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
649*38fd1498Szrj 	      const multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
650*38fd1498Szrj     { return __rhs < __lhs; }
651*38fd1498Szrj 
652*38fd1498Szrj   template<typename _Key, typename _Tp,
653*38fd1498Szrj 	   typename _Compare, typename _Allocator>
654*38fd1498Szrj     inline void
655*38fd1498Szrj     swap(multimap<_Key, _Tp, _Compare, _Allocator>& __lhs,
656*38fd1498Szrj 	 multimap<_Key, _Tp, _Compare, _Allocator>& __rhs)
657*38fd1498Szrj     _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
658*38fd1498Szrj     { __lhs.swap(__rhs); }
659*38fd1498Szrj 
660*38fd1498Szrj } // namespace __profile
661*38fd1498Szrj } // namespace std
662*38fd1498Szrj 
663*38fd1498Szrj #endif
664