libstdc++
|
00001 // Debugging support implementation -*- C++ -*- 00002 00003 // Copyright (C) 2015-2018 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 #if __cplusplus < 201103L 00051 template<typename _Iterator> 00052 struct __is_safe_random_iterator<std::reverse_iterator<_Iterator> > 00053 : __is_safe_random_iterator<_Iterator> 00054 { }; 00055 00056 template<typename _Iterator> 00057 struct _Unsafe_type<std::reverse_iterator<_Iterator> > 00058 { 00059 typedef typename _Unsafe_type<_Iterator>::_Type _UnsafeType; 00060 typedef std::reverse_iterator<_UnsafeType> _Type; 00061 }; 00062 00063 template<typename _Iterator> 00064 inline std::reverse_iterator<typename _Unsafe_type<_Iterator>::_Type> 00065 __unsafe(const std::reverse_iterator<_Iterator>& __it) 00066 { 00067 typedef typename _Unsafe_type<_Iterator>::_Type _UnsafeType; 00068 return std::reverse_iterator<_UnsafeType>(__unsafe(__it.base())); 00069 } 00070 #else 00071 template<typename _Iterator> 00072 inline auto 00073 __base(const std::reverse_iterator<_Iterator>& __it) 00074 -> decltype(std::__make_reverse_iterator(__base(__it.base()))) 00075 { return std::__make_reverse_iterator(__base(__it.base())); } 00076 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> 00100 inline auto 00101 __unsafe(const std::move_iterator<_Iterator>& __it) 00102 -> decltype(std::make_move_iterator(__unsafe(__it.base()))) 00103 { return std::make_move_iterator(__unsafe(__it.base())); } 00104 00105 template<typename _Iterator> 00106 inline auto 00107 __base(const std::move_iterator<_Iterator>& __it) 00108 -> decltype(std::make_move_iterator(__base(__it.base()))) 00109 { return std::make_move_iterator(__base(__it.base())); } 00110 #endif 00111 } 00112 00113 #endif