mirror of
https://github.com/gcc-mirror/gcc.git
synced 2026-05-06 14:59:39 +02:00
libstdc++: [_GLIBCXX_DEBUG][__cplusplus >= 201103L] Remove useless workaround
Starting with C++11 we leverage on template parameter requirement to prevent instantiation of methods taking iterators with invalid types. So the _GLIBCXX_DEBUG mode do not need to check for potential ambiguity between integer type and iterator type anymore. libstdc++-v3/ChangeLog: * include/debug/functions.h [__cplusplus >= 201103L] (__foreign_iterator_aux): Remove. (__foreign_iterator): Adapt to use __foreign_iterator_aux2. * include/debug/helper_functions.h [__cplusplus >= 201103L]: Remove include bits/cpp_type_traits.h. (_Distance_traits<_Integral, std::__true_type>): Remove. (__valid_range_aux(_Integral, _Integral, std::__true_type)): Remove. (__valid_range_aux(_Iterator, _Iterator, std::__false_type)): Remove. (__valid_range_aux(_Integral, _Integral, _Distance_traits<_Integral>::__type&, std::__true_type)): Remove. (__valid_range_aux(_Iterator, _Iterator, _Distance_traits<_Iterator>::__type&, std::__false_type)): Remove. (__valid_range(_Iterator, _Iterator)): Adapt. (__valid_range(_Iterator, _Iterator, _Distance_traits<_Iterator>::__type&)): Adapt. Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
This commit is contained in:
committed by
François Dumont
parent
9f99ee9d10
commit
698a6af5dc
@@ -168,6 +168,7 @@ namespace __gnu_debug
|
||||
return __foreign_iterator_aux3(__it, __other, __other_end, __tag());
|
||||
}
|
||||
|
||||
#if __cplusplus < 201103L
|
||||
/* Handle the case where we aren't really inserting a range after all */
|
||||
template<typename _Iterator, typename _Sequence, typename _Category,
|
||||
typename _Integral>
|
||||
@@ -185,12 +186,21 @@ namespace __gnu_debug
|
||||
const _Safe_iterator<_Iterator, _Sequence, _Category>& __it,
|
||||
_InputIterator __other, _InputIterator __other_end,
|
||||
std::__false_type)
|
||||
#else
|
||||
template<typename _Iterator, typename _Sequence, typename _Category,
|
||||
typename _InputIterator>
|
||||
inline bool
|
||||
__foreign_iterator(
|
||||
const _Safe_iterator<_Iterator, _Sequence, _Category>& __it,
|
||||
_InputIterator __other, _InputIterator __other_end)
|
||||
#endif
|
||||
{
|
||||
return _Insert_range_from_self_is_safe<_Sequence>::__value
|
||||
|| __foreign_iterator_aux2(__it, std::__miter_base(__other),
|
||||
std::__miter_base(__other_end));
|
||||
}
|
||||
|
||||
#if __cplusplus < 201103L
|
||||
template<typename _Iterator, typename _Sequence, typename _Category,
|
||||
typename _InputIterator>
|
||||
inline bool
|
||||
@@ -201,6 +211,7 @@ namespace __gnu_debug
|
||||
typedef typename std::__is_integer<_InputIterator>::__type _Integral;
|
||||
return __foreign_iterator_aux(__it, __other, __other_end, _Integral());
|
||||
}
|
||||
#endif
|
||||
|
||||
// Can't check if an input iterator sequence is sorted, because we
|
||||
// can't step through the sequence.
|
||||
|
||||
@@ -32,7 +32,9 @@
|
||||
#include <bits/move.h> // for __addressof
|
||||
#include <bits/stl_iterator_base_types.h> // for iterator_traits,
|
||||
// categories and _Iter_base
|
||||
#include <bits/cpp_type_traits.h> // for __is_integer
|
||||
#if __cplusplus < 201103L
|
||||
# include <bits/cpp_type_traits.h> // for __is_integer
|
||||
#endif
|
||||
|
||||
#include <bits/stl_pair.h> // for pair
|
||||
|
||||
@@ -58,8 +60,12 @@ namespace __gnu_debug
|
||||
__dp_exact //< Can determine distance precisely
|
||||
};
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
template<typename _Iterator>
|
||||
#else
|
||||
template<typename _Iterator,
|
||||
typename = typename std::__is_integer<_Iterator>::__type>
|
||||
#endif
|
||||
struct _Distance_traits
|
||||
{
|
||||
private:
|
||||
@@ -80,9 +86,11 @@ namespace __gnu_debug
|
||||
typedef std::pair<_DiffType, _Distance_precision> __type;
|
||||
};
|
||||
|
||||
#if __cplusplus < 201103L
|
||||
template<typename _Integral>
|
||||
struct _Distance_traits<_Integral, std::__true_type>
|
||||
{ typedef std::pair<std::ptrdiff_t, _Distance_precision> __type; };
|
||||
#endif
|
||||
|
||||
/** Determine the distance between two iterators with some known
|
||||
* precision.
|
||||
@@ -141,18 +149,14 @@ namespace __gnu_debug
|
||||
__check_singular(_Tp* const& __ptr)
|
||||
{ return __ptr == 0; }
|
||||
|
||||
/** We say that integral types for a valid range, and defer to other
|
||||
* routines to realize what to do with integral types instead of
|
||||
* iterators.
|
||||
*/
|
||||
#if __cplusplus < 201103L
|
||||
// In case of integral type no assertions.
|
||||
template<typename _Integral>
|
||||
_GLIBCXX_CONSTEXPR
|
||||
inline bool
|
||||
__valid_range_aux(_Integral, _Integral, std::__true_type)
|
||||
{ return true; }
|
||||
|
||||
template<typename _Integral>
|
||||
_GLIBCXX20_CONSTEXPR
|
||||
inline bool
|
||||
__valid_range_aux(_Integral, _Integral,
|
||||
typename _Distance_traits<_Integral>::__type& __dist,
|
||||
@@ -161,6 +165,7 @@ namespace __gnu_debug
|
||||
__dist = std::make_pair(0, __dp_none);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
template<typename _InputIterator>
|
||||
_GLIBCXX_CONSTEXPR
|
||||
@@ -189,25 +194,37 @@ namespace __gnu_debug
|
||||
&& __first <= __last;
|
||||
}
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
template<typename _InputIterator>
|
||||
constexpr bool
|
||||
__valid_range(_InputIterator __first, _InputIterator __last)
|
||||
#else
|
||||
/** We have iterators, so figure out what kind of iterators they are
|
||||
* to see if we can check the range ahead of time.
|
||||
*/
|
||||
template<typename _InputIterator>
|
||||
_GLIBCXX_CONSTEXPR
|
||||
inline bool
|
||||
__valid_range_aux(_InputIterator __first, _InputIterator __last,
|
||||
std::__false_type)
|
||||
#endif
|
||||
{
|
||||
return __gnu_debug::__valid_range_aux(__first, __last,
|
||||
std::__iterator_category(__first));
|
||||
}
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
template<typename _InputIterator>
|
||||
_GLIBCXX20_CONSTEXPR
|
||||
inline bool
|
||||
__valid_range(_InputIterator __first, _InputIterator __last,
|
||||
typename _Distance_traits<_InputIterator>::__type& __dist)
|
||||
#else
|
||||
template<typename _InputIterator>
|
||||
inline bool
|
||||
__valid_range_aux(_InputIterator __first, _InputIterator __last,
|
||||
typename _Distance_traits<_InputIterator>::__type& __dist,
|
||||
std::__false_type)
|
||||
#endif
|
||||
{
|
||||
if (!__gnu_debug::__valid_range_aux(__first, __last,
|
||||
std::input_iterator_tag()))
|
||||
@@ -232,13 +249,13 @@ namespace __gnu_debug
|
||||
return true;
|
||||
}
|
||||
|
||||
#if __cplusplus < 201103L
|
||||
/** Don't know what these iterators are, or if they are even
|
||||
* iterators (we may get an integral type for InputIterator), so
|
||||
* see if they are integral and pass them on to the next phase
|
||||
* otherwise.
|
||||
*/
|
||||
template<typename _InputIterator>
|
||||
_GLIBCXX20_CONSTEXPR
|
||||
inline bool
|
||||
__valid_range(_InputIterator __first, _InputIterator __last,
|
||||
typename _Distance_traits<_InputIterator>::__type& __dist)
|
||||
@@ -247,6 +264,7 @@ namespace __gnu_debug
|
||||
return __gnu_debug::__valid_range_aux(__first, __last, __dist,
|
||||
_Integral());
|
||||
}
|
||||
#endif
|
||||
|
||||
template<typename _Iterator, typename _Sequence, typename _Category>
|
||||
_GLIBCXX20_CONSTEXPR bool
|
||||
@@ -262,14 +280,15 @@ namespace __gnu_debug
|
||||
typename _Distance_traits<_Iterator>::__type&);
|
||||
#endif
|
||||
|
||||
#if __cplusplus < 201103L
|
||||
template<typename _InputIterator>
|
||||
_GLIBCXX14_CONSTEXPR
|
||||
inline bool
|
||||
__valid_range(_InputIterator __first, _InputIterator __last)
|
||||
{
|
||||
typedef typename std::__is_integer<_InputIterator>::__type _Integral;
|
||||
return __gnu_debug::__valid_range_aux(__first, __last, _Integral());
|
||||
}
|
||||
#endif
|
||||
|
||||
template<typename _Iterator, typename _Sequence, typename _Category>
|
||||
_GLIBCXX20_CONSTEXPR bool
|
||||
|
||||
Reference in New Issue
Block a user