libstdc++
|
00001 // Debugging support implementation -*- C++ -*- 00002 00003 // Copyright (C) 2015-2019 Free Software Foundation, Inc. 00004 // 00005 // This file is part of the GNU ISO C++ Library. This library is free 00006 // software; you can redistribute it and/or modify it under the 00007 // terms of the GNU General Public License as published by the 00008 // Free Software Foundation; either version 3, or (at your option) 00009 // any later version. 00010 00011 // This library is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU General Public License for more details. 00015 00016 // Under Section 7 of GPL version 3, you are granted additional 00017 // permissions described in the GCC Runtime Library Exception, version 00018 // 3.1, as published by the Free Software Foundation. 00019 00020 // You should have received a copy of the GNU General Public License and 00021 // a copy of the GCC Runtime Library Exception along with this program; 00022 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 00023 // <http://www.gnu.org/licenses/>. 00024 00025 /** @file debug/stl_iterator.h 00026 * This file is a GNU debug extension to the Standard C++ Library. 00027 */ 00028 00029 #ifndef _GLIBCXX_DEBUG_STL_ITERATOR_H 00030 #define _GLIBCXX_DEBUG_STL_ITERATOR_H 1 00031 00032 #include <debug/helper_functions.h> 00033 00034 namespace __gnu_debug 00035 { 00036 // Help Debug mode to see through reverse_iterator. 00037 template<typename _Iterator> 00038 inline bool 00039 __valid_range(const std::reverse_iterator<_Iterator>& __first, 00040 const std::reverse_iterator<_Iterator>& __last, 00041 typename _Distance_traits<_Iterator>::__type& __dist) 00042 { return __valid_range(__last.base(), __first.base(), __dist); } 00043 00044 template<typename _Iterator> 00045 inline typename _Distance_traits<_Iterator>::__type 00046 __get_distance(const std::reverse_iterator<_Iterator>& __first, 00047 const std::reverse_iterator<_Iterator>& __last) 00048 { return __get_distance(__last.base(), __first.base()); } 00049 00050 template<typename _Iterator, typename _Size> 00051 inline bool 00052 __can_advance(const std::reverse_iterator<_Iterator>& __it, _Size __n) 00053 { return __can_advance(__it.base(), -__n); } 00054 00055 template<typename _Iterator, typename _Sequence> 00056 inline std::reverse_iterator<_Iterator> 00057 __base(const std::reverse_iterator<_Safe_iterator< 00058 _Iterator, _Sequence, std::random_access_iterator_tag> >& __it) 00059 { return std::reverse_iterator<_Iterator>(__it.base().base()); } 00060 00061 #if __cplusplus < 201103L 00062 template<typename _Iterator> 00063 struct _Unsafe_type<std::reverse_iterator<_Iterator> > 00064 { 00065 typedef typename _Unsafe_type<_Iterator>::_Type _UnsafeType; 00066 typedef std::reverse_iterator<_UnsafeType> _Type; 00067 }; 00068 00069 template<typename _Iterator> 00070 inline std::reverse_iterator<typename _Unsafe_type<_Iterator>::_Type> 00071 __unsafe(const std::reverse_iterator<_Iterator>& __it) 00072 { 00073 typedef typename _Unsafe_type<_Iterator>::_Type _UnsafeType; 00074 return std::reverse_iterator<_UnsafeType>(__unsafe(__it.base())); 00075 } 00076 #else 00077 template<typename _Iterator> 00078 inline auto 00079 __unsafe(const std::reverse_iterator<_Iterator>& __it) 00080 -> decltype(std::__make_reverse_iterator(__unsafe(__it.base()))) 00081 { return std::__make_reverse_iterator(__unsafe(__it.base())); } 00082 #endif 00083 00084 #if __cplusplus >= 201103L 00085 // Help Debug mode to see through move_iterator. 00086 template<typename _Iterator> 00087 inline bool 00088 __valid_range(const std::move_iterator<_Iterator>& __first, 00089 const std::move_iterator<_Iterator>& __last, 00090 typename _Distance_traits<_Iterator>::__type& __dist) 00091 { return __valid_range(__first.base(), __last.base(), __dist); } 00092 00093 template<typename _Iterator> 00094 inline typename _Distance_traits<_Iterator>::__type 00095 __get_distance(const std::move_iterator<_Iterator>& __first, 00096 const std::move_iterator<_Iterator>& __last) 00097 { return __get_distance(__first.base(), __last.base()); } 00098 00099 template<typename _Iterator, typename _Size> 00100 inline bool 00101 __can_advance(const std::move_iterator<_Iterator>& __it, _Size __n) 00102 { return __can_advance(__it.base(), __n); } 00103 00104 template<typename _Iterator> 00105 inline auto 00106 __unsafe(const std::move_iterator<_Iterator>& __it) 00107 -> decltype(std::make_move_iterator(__unsafe(__it.base()))) 00108 { return std::make_move_iterator(__unsafe(__it.base())); } 00109 00110 template<typename _Iterator> 00111 inline auto 00112 __base(const std::move_iterator<_Iterator>& __it) 00113 -> decltype(std::make_move_iterator(__base(__it.base()))) 00114 { return std::make_move_iterator(__base(__it.base())); } 00115 #endif 00116 } 00117 00118 namespace std 00119 { 00120 _GLIBCXX_BEGIN_NAMESPACE_VERSION 00121 00122 template<typename _Iterator, typename _Container, typename _Sequence> 00123 _Iterator 00124 __niter_base(const __gnu_debug::_Safe_iterator< 00125 __gnu_cxx::__normal_iterator<_Iterator, _Container>, 00126 _Sequence, std::random_access_iterator_tag>&); 00127 00128 _GLIBCXX_END_NAMESPACE_VERSION 00129 } 00130 00131 #endif