source: Daodan/MSYS2/mingw32/include/c++/11.2.0/debug/stl_iterator.h@ 1194

Last change on this file since 1194 was 1166, checked in by rossy, 3 years ago

Daodan: Replace MinGW build env with an up-to-date MSYS2 env

File size: 4.9 KB
Line 
1// Debugging support implementation -*- C++ -*-
2
3// Copyright (C) 2015-2021 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.
10
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.
15
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.
19
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/>.
24
25/** @file debug/stl_iterator.h
26 * This file is a GNU debug extension to the Standard C++ Library.
27 */
28
29#ifndef _GLIBCXX_DEBUG_STL_ITERATOR_H
30#define _GLIBCXX_DEBUG_STL_ITERATOR_H 1
31
32#include <debug/helper_functions.h>
33
34namespace __gnu_debug
35{
36 // Help Debug mode to see through reverse_iterator.
37 template<typename _Iterator>
38 inline bool
39 __valid_range(const std::reverse_iterator<_Iterator>& __first,
40 const std::reverse_iterator<_Iterator>& __last,
41 typename _Distance_traits<_Iterator>::__type& __dist)
42 { return __valid_range(__last.base(), __first.base(), __dist); }
43
44 template<typename _Iterator>
45 inline typename _Distance_traits<_Iterator>::__type
46 __get_distance(const std::reverse_iterator<_Iterator>& __first,
47 const std::reverse_iterator<_Iterator>& __last)
48 { return __get_distance(__last.base(), __first.base()); }
49
50 template<typename _Iterator, typename _Size>
51 inline bool
52 __can_advance(const std::reverse_iterator<_Iterator>& __it, _Size __n)
53 { return __can_advance(__it.base(), -__n); }
54
55 template<typename _Iterator, typename _Diff>
56 inline bool
57 __can_advance(const std::reverse_iterator<_Iterator>& __it,
58 const std::pair<_Diff, _Distance_precision>& __dist,
59 int __way)
60 { return __can_advance(__it.base(), __dist, -__way); }
61
62 template<typename _Iterator, typename _Sequence>
63 inline std::reverse_iterator<_Iterator>
64 __base(const std::reverse_iterator<_Safe_iterator<
65 _Iterator, _Sequence, std::random_access_iterator_tag> >& __it)
66 { return std::reverse_iterator<_Iterator>(__it.base().base()); }
67
68#if __cplusplus < 201103L
69 template<typename _Iterator>
70 struct _Unsafe_type<std::reverse_iterator<_Iterator> >
71 {
72 typedef typename _Unsafe_type<_Iterator>::_Type _UnsafeType;
73 typedef std::reverse_iterator<_UnsafeType> _Type;
74 };
75
76 template<typename _Iterator>
77 inline std::reverse_iterator<typename _Unsafe_type<_Iterator>::_Type>
78 __unsafe(const std::reverse_iterator<_Iterator>& __it)
79 {
80 typedef typename _Unsafe_type<_Iterator>::_Type _UnsafeType;
81 return std::reverse_iterator<_UnsafeType>(__unsafe(__it.base()));
82 }
83#else
84 template<typename _Iterator>
85 inline auto
86 __unsafe(const std::reverse_iterator<_Iterator>& __it)
87 -> decltype(std::__make_reverse_iterator(__unsafe(__it.base())))
88 { return std::__make_reverse_iterator(__unsafe(__it.base())); }
89#endif
90
91#if __cplusplus >= 201103L
92 // Help Debug mode to see through move_iterator.
93 template<typename _Iterator>
94 inline bool
95 __valid_range(const std::move_iterator<_Iterator>& __first,
96 const std::move_iterator<_Iterator>& __last,
97 typename _Distance_traits<_Iterator>::__type& __dist)
98 { return __valid_range(__first.base(), __last.base(), __dist); }
99
100 template<typename _Iterator>
101 inline typename _Distance_traits<_Iterator>::__type
102 __get_distance(const std::move_iterator<_Iterator>& __first,
103 const std::move_iterator<_Iterator>& __last)
104 { return __get_distance(__first.base(), __last.base()); }
105
106 template<typename _Iterator, typename _Size>
107 inline bool
108 __can_advance(const std::move_iterator<_Iterator>& __it, _Size __n)
109 { return __can_advance(__it.base(), __n); }
110
111 template<typename _Iterator, typename _Diff>
112 inline bool
113 __can_advance(const std::move_iterator<_Iterator>& __it,
114 const std::pair<_Diff, _Distance_precision>& __dist,
115 int __way)
116 { return __can_advance(__it.base(), __dist, __way); }
117
118 template<typename _Iterator>
119 inline auto
120 __unsafe(const std::move_iterator<_Iterator>& __it)
121 -> decltype(std::make_move_iterator(__unsafe(__it.base())))
122 { return std::make_move_iterator(__unsafe(__it.base())); }
123
124 template<typename _Iterator>
125 inline auto
126 __base(const std::move_iterator<_Iterator>& __it)
127 -> decltype(std::make_move_iterator(__base(__it.base())))
128 { return std::make_move_iterator(__base(__it.base())); }
129#endif
130}
131
132#endif
Note: See TracBrowser for help on using the repository browser.