summaryrefslogtreecommitdiff
path: root/libstdc++-v3/include
diff options
context:
space:
mode:
authorfdumont <fdumont@138bc75d-0d04-0410-961f-82ee72b054a4>2013-08-30 20:55:37 +0000
committerfdumont <fdumont@138bc75d-0d04-0410-961f-82ee72b054a4>2013-08-30 20:55:37 +0000
commitdc84fdc8469593faa45895d7e5bcb1f166d6af9c (patch)
treeabdc94081f8c6075d64ba9ed54dbdd2100f880e8 /libstdc++-v3/include
parent096d86ac43617dcf367ece0dabe3a65d844c2247 (diff)
downloadgcc-dc84fdc8469593faa45895d7e5bcb1f166d6af9c.tar.gz
2013-08-30 François Dumont <fdumont@gcc.gnu.org>
PR libstdc++/58148 * include/debug/functions.h (__foreign_iterator_aux4): Use sequence const_pointer as common type to compare pointers. Add a fallback overload in case pointers cannot be cast to sequence const_pointer. * testsuite/23_containers/vector/modifiers/insert/58148.cc: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@202121 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include')
-rw-r--r--libstdc++-v3/include/debug/functions.h39
1 files changed, 21 insertions, 18 deletions
diff --git a/libstdc++-v3/include/debug/functions.h b/libstdc++-v3/include/debug/functions.h
index 650793065c3..8e76b7f2ee5 100644
--- a/libstdc++-v3/include/debug/functions.h
+++ b/libstdc++-v3/include/debug/functions.h
@@ -36,7 +36,7 @@
#include <bits/move.h> // for __addressof and addressof
#if __cplusplus >= 201103L
# include <bits/stl_function.h> // for less and greater_equal
-# include <type_traits> // for common_type
+# include <type_traits> // for is_lvalue_reference and __and_
#endif
#include <debug/formatter.h>
@@ -172,27 +172,30 @@ namespace __gnu_debug
}
#if __cplusplus >= 201103L
- template<typename _Iterator, typename _Sequence,
- typename _InputIterator,
- typename _PointerType1,
- typename _PointerType2>
+ // Default implementation.
+ template<typename _Iterator, typename _Sequence>
inline bool
__foreign_iterator_aux4(const _Safe_iterator<_Iterator, _Sequence>& __it,
- _InputIterator __other,
- _PointerType1, _PointerType2)
+ typename _Sequence::const_pointer __begin,
+ typename _Sequence::const_pointer __other)
{
- typedef typename std::common_type<_PointerType1,
- _PointerType2>::type _PointerType;
+ typedef typename _Sequence::const_pointer _PointerType;
constexpr std::less<_PointerType> __l{};
- constexpr std::greater_equal<_PointerType> __ge{};
- return (__l(std::addressof(*__other),
- std::addressof(*(__it._M_get_sequence()->_M_base().begin())))
- || __ge(std::addressof(*__other),
- std::addressof(*(__it._M_get_sequence()->_M_base().end()
- - 1)) + 1));
+ return (__l(__other, __begin)
+ || __l(std::addressof(*(__it._M_get_sequence()->_M_base().end()
+ - 1)), __other));
}
-
+
+ // Fallback when address type cannot be implicitely casted to sequence
+ // const_pointer.
+ template<typename _Iterator, typename _Sequence,
+ typename _InputIterator>
+ inline bool
+ __foreign_iterator_aux4(const _Safe_iterator<_Iterator, _Sequence>&,
+ _InputIterator, ...)
+ { return true; }
+
template<typename _Iterator, typename _Sequence, typename _InputIterator>
inline bool
__foreign_iterator_aux3(const _Safe_iterator<_Iterator, _Sequence>& __it,
@@ -209,7 +212,7 @@ namespace __gnu_debug
- std::addressof(*(__it._M_get_sequence()->_M_base().begin()))
== __it._M_get_sequence()->size() - 1)
return (__foreign_iterator_aux4
- (__it, __other,
+ (__it,
std::addressof(*(__it._M_get_sequence()->_M_base().begin())),
std::addressof(*__other)));
return true;
@@ -223,7 +226,7 @@ namespace __gnu_debug
std::false_type)
{ return true; }
#endif
-
+
/** Checks that iterators do not belong to the same sequence. */
template<typename _Iterator, typename _Sequence, typename _OtherIterator>
inline bool