Commit 8915a229 by François Dumont

re PR libstdc++/58191 (Can't use boost transform_iterator with _GLIBCXX_DEBUG)

2013-08-30  François Dumont  <fdumont@gcc.gnu.org>

	PR libstdc++/58191
	* include/debug/macros.h (__glibcxx_check_partitioned_lower): Add
	__gnu_debug::__base calls on iterators passed to internal debug
	check.
	(__glibcxx_check_partitioned_lower_pred): Likewise.
	(__glibcxx_check_partitioned_upper): Likewise.
	(__glibcxx_check_partitioned_upper_pred): Likewise.
	(__glibcxx_check_sorted): Likewise.
	(__glibcxx_check_sorted_pred): Likewise.
	(__glibcxx_check_sorted_set): Likewise.
	(__glibcxx_check_sorted_set_pred): Likewise.
	* include/debug/functions.h (__check_partitioned_lower):
	Remove code to detect safe iterators.
	(__check_partitioned_upper): Likewise.
	(__check_sorted): Likewise.

From-SVN: r202119
parent 3ecee8f7
2013-08-30 François Dumont <fdumont@gcc.gnu.org>
PR libstdc++/58191
* include/debug/macros.h (__glibcxx_check_partitioned_lower): Add
__gnu_debug::__base calls on iterators passed to internal debug
check.
(__glibcxx_check_partitioned_lower_pred): Likewise.
(__glibcxx_check_partitioned_upper): Likewise.
(__glibcxx_check_partitioned_upper_pred): Likewise.
(__glibcxx_check_sorted): Likewise.
(__glibcxx_check_sorted_pred): Likewise.
(__glibcxx_check_sorted_set): Likewise.
(__glibcxx_check_sorted_set_pred): Likewise.
* include/debug/functions.h (__check_partitioned_lower):
Remove code to detect safe iterators.
(__check_partitioned_upper): Likewise.
(__check_sorted): Likewise.
2013-08-29 Tim Shen <timshen91@gmail.com> 2013-08-29 Tim Shen <timshen91@gmail.com>
* include/bits/regex.h (basic_regex<>::assign): Don't lose _M_traits. * include/bits/regex.h (basic_regex<>::assign): Don't lose _M_traits.
......
...@@ -336,15 +336,6 @@ namespace __gnu_debug ...@@ -336,15 +336,6 @@ namespace __gnu_debug
return true; return true;
} }
// For performance reason, as the iterator range has been validated, check on
// random access safe iterators is done using the base iterator.
template<typename _Iterator, typename _Sequence>
inline bool
__check_sorted_aux(const _Safe_iterator<_Iterator, _Sequence>& __first,
const _Safe_iterator<_Iterator, _Sequence>& __last,
std::random_access_iterator_tag __tag)
{ return __check_sorted_aux(__first.base(), __last.base(), __tag); }
// Can't check if an input iterator sequence is sorted, because we can't step // Can't check if an input iterator sequence is sorted, because we can't step
// through the sequence. // through the sequence.
template<typename _InputIterator, typename _Predicate> template<typename _InputIterator, typename _Predicate>
...@@ -371,17 +362,6 @@ namespace __gnu_debug ...@@ -371,17 +362,6 @@ namespace __gnu_debug
return true; return true;
} }
// For performance reason, as the iterator range has been validated, check on
// random access safe iterators is done using the base iterator.
template<typename _Iterator, typename _Sequence,
typename _Predicate>
inline bool
__check_sorted_aux(const _Safe_iterator<_Iterator, _Sequence>& __first,
const _Safe_iterator<_Iterator, _Sequence>& __last,
_Predicate __pred,
std::random_access_iterator_tag __tag)
{ return __check_sorted_aux(__first.base(), __last.base(), __pred, __tag); }
// Determine if a sequence is sorted. // Determine if a sequence is sorted.
template<typename _InputIterator> template<typename _InputIterator>
inline bool inline bool
...@@ -470,11 +450,13 @@ namespace __gnu_debug ...@@ -470,11 +450,13 @@ namespace __gnu_debug
return __check_sorted_set_aux(__first, __last, __pred, _SameType()); return __check_sorted_set_aux(__first, __last, __pred, _SameType());
} }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 270. Binary search requirements overly strict
// Determine if a sequence is partitioned w.r.t. this element.
template<typename _ForwardIterator, typename _Tp> template<typename _ForwardIterator, typename _Tp>
inline bool inline bool
__check_partitioned_lower_aux(_ForwardIterator __first, __check_partitioned_lower(_ForwardIterator __first,
_ForwardIterator __last, const _Tp& __value, _ForwardIterator __last, const _Tp& __value)
std::forward_iterator_tag)
{ {
while (__first != __last && *__first < __value) while (__first != __last && *__first < __value)
++__first; ++__first;
...@@ -487,38 +469,11 @@ namespace __gnu_debug ...@@ -487,38 +469,11 @@ namespace __gnu_debug
return __first == __last; return __first == __last;
} }
// For performance reason, as the iterator range has been validated, check on
// random access safe iterators is done using the base iterator.
template<typename _Iterator, typename _Sequence, typename _Tp>
inline bool
__check_partitioned_lower_aux(
const _Safe_iterator<_Iterator, _Sequence>& __first,
const _Safe_iterator<_Iterator, _Sequence>& __last,
const _Tp& __value,
std::random_access_iterator_tag __tag)
{
return __check_partitioned_lower_aux(__first.base(), __last.base(),
__value, __tag);
}
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 270. Binary search requirements overly strict
// Determine if a sequence is partitioned w.r.t. this element.
template<typename _ForwardIterator, typename _Tp> template<typename _ForwardIterator, typename _Tp>
inline bool inline bool
__check_partitioned_lower(_ForwardIterator __first, __check_partitioned_upper(_ForwardIterator __first,
_ForwardIterator __last, const _Tp& __value) _ForwardIterator __last, const _Tp& __value)
{ {
return __check_partitioned_lower_aux(__first, __last, __value,
std::__iterator_category(__first));
}
template<typename _ForwardIterator, typename _Tp>
inline bool
__check_partitioned_upper_aux(_ForwardIterator __first,
_ForwardIterator __last, const _Tp& __value,
std::forward_iterator_tag)
{
while (__first != __last && !(__value < *__first)) while (__first != __last && !(__value < *__first))
++__first; ++__first;
if (__first != __last) if (__first != __last)
...@@ -530,35 +485,12 @@ namespace __gnu_debug ...@@ -530,35 +485,12 @@ namespace __gnu_debug
return __first == __last; return __first == __last;
} }
// For performance reason, as the iterator range has been validated, check on // Determine if a sequence is partitioned w.r.t. this element.
// random access safe iterators is done using the base iterator.
template<typename _Iterator, typename _Sequence, typename _Tp>
inline bool
__check_partitioned_upper_aux(
const _Safe_iterator<_Iterator, _Sequence>& __first,
const _Safe_iterator<_Iterator, _Sequence>& __last,
const _Tp& __value,
std::random_access_iterator_tag __tag)
{
return __check_partitioned_upper_aux(__first.base(), __last.base(),
__value, __tag);
}
template<typename _ForwardIterator, typename _Tp>
inline bool
__check_partitioned_upper(_ForwardIterator __first,
_ForwardIterator __last, const _Tp& __value)
{
return __check_partitioned_upper_aux(__first, __last, __value,
std::__iterator_category(__first));
}
template<typename _ForwardIterator, typename _Tp, typename _Pred> template<typename _ForwardIterator, typename _Tp, typename _Pred>
inline bool inline bool
__check_partitioned_lower_aux(_ForwardIterator __first, __check_partitioned_lower(_ForwardIterator __first,
_ForwardIterator __last, const _Tp& __value, _ForwardIterator __last, const _Tp& __value,
_Pred __pred, _Pred __pred)
std::forward_iterator_tag)
{ {
while (__first != __last && bool(__pred(*__first, __value))) while (__first != __last && bool(__pred(*__first, __value)))
++__first; ++__first;
...@@ -571,39 +503,12 @@ namespace __gnu_debug ...@@ -571,39 +503,12 @@ namespace __gnu_debug
return __first == __last; return __first == __last;
} }
// For performance reason, as the iterator range has been validated, check on
// random access safe iterators is done using the base iterator.
template<typename _Iterator, typename _Sequence,
typename _Tp, typename _Pred>
inline bool
__check_partitioned_lower_aux(
const _Safe_iterator<_Iterator, _Sequence>& __first,
const _Safe_iterator<_Iterator, _Sequence>& __last,
const _Tp& __value, _Pred __pred,
std::random_access_iterator_tag __tag)
{
return __check_partitioned_lower_aux(__first.base(), __last.base(),
__value, __pred, __tag);
}
// Determine if a sequence is partitioned w.r.t. this element.
template<typename _ForwardIterator, typename _Tp, typename _Pred> template<typename _ForwardIterator, typename _Tp, typename _Pred>
inline bool inline bool
__check_partitioned_lower(_ForwardIterator __first, __check_partitioned_upper(_ForwardIterator __first,
_ForwardIterator __last, const _Tp& __value, _ForwardIterator __last, const _Tp& __value,
_Pred __pred) _Pred __pred)
{ {
return __check_partitioned_lower_aux(__first, __last, __value, __pred,
std::__iterator_category(__first));
}
template<typename _ForwardIterator, typename _Tp, typename _Pred>
inline bool
__check_partitioned_upper_aux(_ForwardIterator __first,
_ForwardIterator __last, const _Tp& __value,
_Pred __pred,
std::forward_iterator_tag)
{
while (__first != __last && !bool(__pred(__value, *__first))) while (__first != __last && !bool(__pred(__value, *__first)))
++__first; ++__first;
if (__first != __last) if (__first != __last)
...@@ -615,31 +520,6 @@ namespace __gnu_debug ...@@ -615,31 +520,6 @@ namespace __gnu_debug
return __first == __last; return __first == __last;
} }
// For performance reason, as the iterator range has been validated, check on
// random access safe iterators is done using the base iterator.
template<typename _Iterator, typename _Sequence,
typename _Tp, typename _Pred>
inline bool
__check_partitioned_upper_aux(
const _Safe_iterator<_Iterator, _Sequence>& __first,
const _Safe_iterator<_Iterator, _Sequence>& __last,
const _Tp& __value, _Pred __pred,
std::random_access_iterator_tag __tag)
{
return __check_partitioned_upper_aux(__first.base(), __last.base(),
__value, __pred, __tag);
}
template<typename _ForwardIterator, typename _Tp, typename _Pred>
inline bool
__check_partitioned_upper(_ForwardIterator __first,
_ForwardIterator __last, const _Tp& __value,
_Pred __pred)
{
return __check_partitioned_upper_aux(__first, __last, __value, __pred,
std::__iterator_category(__first));
}
// Helper struct to detect random access safe iterators. // Helper struct to detect random access safe iterators.
template<typename _Iterator> template<typename _Iterator>
struct __is_safe_random_iterator struct __is_safe_random_iterator
......
...@@ -229,7 +229,9 @@ _GLIBCXX_DEBUG_VERIFY(! this->empty(), \ ...@@ -229,7 +229,9 @@ _GLIBCXX_DEBUG_VERIFY(! this->empty(), \
// Verify that the iterator range [_First, _Last) is sorted // Verify that the iterator range [_First, _Last) is sorted
#define __glibcxx_check_sorted(_First,_Last) \ #define __glibcxx_check_sorted(_First,_Last) \
__glibcxx_check_valid_range(_First,_Last); \ __glibcxx_check_valid_range(_First,_Last); \
_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted(_First, _Last), \ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted( \
__gnu_debug::__base(_First), \
__gnu_debug::__base(_Last)), \
_M_message(__gnu_debug::__msg_unsorted) \ _M_message(__gnu_debug::__msg_unsorted) \
._M_iterator(_First, #_First) \ ._M_iterator(_First, #_First) \
._M_iterator(_Last, #_Last)) ._M_iterator(_Last, #_Last))
...@@ -238,7 +240,9 @@ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted(_First, _Last), \ ...@@ -238,7 +240,9 @@ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted(_First, _Last), \
predicate _Pred. */ predicate _Pred. */
#define __glibcxx_check_sorted_pred(_First,_Last,_Pred) \ #define __glibcxx_check_sorted_pred(_First,_Last,_Pred) \
__glibcxx_check_valid_range(_First,_Last); \ __glibcxx_check_valid_range(_First,_Last); \
_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted(_First, _Last, _Pred), \ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted( \
__gnu_debug::__base(_First), \
__gnu_debug::__base(_Last), _Pred), \
_M_message(__gnu_debug::__msg_unsorted_pred) \ _M_message(__gnu_debug::__msg_unsorted_pred) \
._M_iterator(_First, #_First) \ ._M_iterator(_First, #_First) \
._M_iterator(_Last, #_Last) \ ._M_iterator(_Last, #_Last) \
...@@ -248,7 +252,8 @@ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted(_First, _Last, _Pred), \ ...@@ -248,7 +252,8 @@ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted(_First, _Last, _Pred), \
#define __glibcxx_check_sorted_set(_First1,_Last1,_First2) \ #define __glibcxx_check_sorted_set(_First1,_Last1,_First2) \
__glibcxx_check_valid_range(_First1,_Last1); \ __glibcxx_check_valid_range(_First1,_Last1); \
_GLIBCXX_DEBUG_VERIFY( \ _GLIBCXX_DEBUG_VERIFY( \
__gnu_debug::__check_sorted_set(_First1, _Last1, _First2), \ __gnu_debug::__check_sorted_set(__gnu_debug::__base(_First1), \
__gnu_debug::__base(_Last1), _First2),\
_M_message(__gnu_debug::__msg_unsorted) \ _M_message(__gnu_debug::__msg_unsorted) \
._M_iterator(_First1, #_First1) \ ._M_iterator(_First1, #_First1) \
._M_iterator(_Last1, #_Last1)) ._M_iterator(_Last1, #_Last1))
...@@ -257,7 +262,9 @@ _GLIBCXX_DEBUG_VERIFY( \ ...@@ -257,7 +262,9 @@ _GLIBCXX_DEBUG_VERIFY( \
#define __glibcxx_check_sorted_set_pred(_First1,_Last1,_First2,_Pred) \ #define __glibcxx_check_sorted_set_pred(_First1,_Last1,_First2,_Pred) \
__glibcxx_check_valid_range(_First1,_Last1); \ __glibcxx_check_valid_range(_First1,_Last1); \
_GLIBCXX_DEBUG_VERIFY( \ _GLIBCXX_DEBUG_VERIFY( \
__gnu_debug::__check_sorted_set(_First1, _Last1, _First2, _Pred), \ __gnu_debug::__check_sorted_set(__gnu_debug::__base(_First1), \
__gnu_debug::__base(_Last1), \
_First2, _Pred), \
_M_message(__gnu_debug::__msg_unsorted_pred) \ _M_message(__gnu_debug::__msg_unsorted_pred) \
._M_iterator(_First1, #_First1) \ ._M_iterator(_First1, #_First1) \
._M_iterator(_Last1, #_Last1) \ ._M_iterator(_Last1, #_Last1) \
...@@ -267,8 +274,9 @@ _GLIBCXX_DEBUG_VERIFY( \ ...@@ -267,8 +274,9 @@ _GLIBCXX_DEBUG_VERIFY( \
w.r.t. the value _Value. */ w.r.t. the value _Value. */
#define __glibcxx_check_partitioned_lower(_First,_Last,_Value) \ #define __glibcxx_check_partitioned_lower(_First,_Last,_Value) \
__glibcxx_check_valid_range(_First,_Last); \ __glibcxx_check_valid_range(_First,_Last); \
_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower(_First, _Last, \ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower( \
_Value), \ __gnu_debug::__base(_First), \
__gnu_debug::__base(_Last), _Value), \
_M_message(__gnu_debug::__msg_unpartitioned) \ _M_message(__gnu_debug::__msg_unpartitioned) \
._M_iterator(_First, #_First) \ ._M_iterator(_First, #_First) \
._M_iterator(_Last, #_Last) \ ._M_iterator(_Last, #_Last) \
...@@ -276,8 +284,9 @@ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower(_First, _Last, \ ...@@ -276,8 +284,9 @@ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower(_First, _Last, \
#define __glibcxx_check_partitioned_upper(_First,_Last,_Value) \ #define __glibcxx_check_partitioned_upper(_First,_Last,_Value) \
__glibcxx_check_valid_range(_First,_Last); \ __glibcxx_check_valid_range(_First,_Last); \
_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper(_First, _Last, \ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper( \
_Value), \ __gnu_debug::__base(_First), \
__gnu_debug::__base(_Last), _Value), \
_M_message(__gnu_debug::__msg_unpartitioned) \ _M_message(__gnu_debug::__msg_unpartitioned) \
._M_iterator(_First, #_First) \ ._M_iterator(_First, #_First) \
._M_iterator(_Last, #_Last) \ ._M_iterator(_Last, #_Last) \
...@@ -287,8 +296,9 @@ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper(_First, _Last, \ ...@@ -287,8 +296,9 @@ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper(_First, _Last, \
w.r.t. the value _Value and predicate _Pred. */ w.r.t. the value _Value and predicate _Pred. */
#define __glibcxx_check_partitioned_lower_pred(_First,_Last,_Value,_Pred) \ #define __glibcxx_check_partitioned_lower_pred(_First,_Last,_Value,_Pred) \
__glibcxx_check_valid_range(_First,_Last); \ __glibcxx_check_valid_range(_First,_Last); \
_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower(_First, _Last, \ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower( \
_Value, _Pred), \ __gnu_debug::__base(_First), \
__gnu_debug::__base(_Last), _Value, _Pred), \
_M_message(__gnu_debug::__msg_unpartitioned_pred) \ _M_message(__gnu_debug::__msg_unpartitioned_pred) \
._M_iterator(_First, #_First) \ ._M_iterator(_First, #_First) \
._M_iterator(_Last, #_Last) \ ._M_iterator(_Last, #_Last) \
...@@ -299,8 +309,9 @@ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower(_First, _Last, \ ...@@ -299,8 +309,9 @@ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower(_First, _Last, \
w.r.t. the value _Value and predicate _Pred. */ w.r.t. the value _Value and predicate _Pred. */
#define __glibcxx_check_partitioned_upper_pred(_First,_Last,_Value,_Pred) \ #define __glibcxx_check_partitioned_upper_pred(_First,_Last,_Value,_Pred) \
__glibcxx_check_valid_range(_First,_Last); \ __glibcxx_check_valid_range(_First,_Last); \
_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper(_First, _Last, \ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper( \
_Value, _Pred), \ __gnu_debug::__base(_First), \
__gnu_debug::__base(_Last), _Value, _Pred), \
_M_message(__gnu_debug::__msg_unpartitioned_pred) \ _M_message(__gnu_debug::__msg_unpartitioned_pred) \
._M_iterator(_First, #_First) \ ._M_iterator(_First, #_First) \
._M_iterator(_Last, #_Last) \ ._M_iterator(_Last, #_Last) \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment