aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/debug/functions.h
diff options
context:
space:
mode:
authorFrançois Dumont <fdumont@gcc.gnu.org>2015-08-24 20:21:57 +0000
committerFrançois Dumont <fdumont@gcc.gnu.org>2015-08-24 20:21:57 +0000
commit41e4e5edce30e6340a8e42e26a19adb2418055c5 (patch)
tree89b7c956187aa4685806c80203e0548bf6a7c7aa /libstdc++-v3/include/debug/functions.h
parent1b533361dae91d9a13679b8377111b91cf554217 (diff)
downloadgcc-41e4e5edce30e6340a8e42e26a19adb2418055c5.zip
gcc-41e4e5edce30e6340a8e42e26a19adb2418055c5.tar.gz
gcc-41e4e5edce30e6340a8e42e26a19adb2418055c5.tar.bz2
formatter.h (_Debug_msg_id::__msg_irreflexive_ordering): New enum entry.
2015-08-24 François Dumont <fdumont@gcc.gnu.org> * include/debug/formatter.h (_Debug_msg_id::__msg_irreflexive_ordering): New enum entry. * include/debug/functions.h (_Irreflexive_checker): New. (__is_irreflexive, __is_irreflexive_pred): New. * include/debug/macros.h (__glibcxx_check_irreflexive, __glibcxx_check_irreflexive_pred): New macros. (__glibcxx_check_irreflexive2, __glibcxx_check_irreflexive_pred2): New macros limited to post-C++11 mode. * include/debug/debug.h (__glibcxx_requires_irreflexive, __glibcxx_requires_irreflexive_pred): New macros, use latter. (__glibcxx_requires_irreflexive2, __glibcxx_requires_irreflexive_pred2): Likewise. * include/bits/stl_algo.h (partial_sort_copy): Add irreflexive debug check. (partial_sort_copy): Likewise. (lower_bound): Likewise. (upper_bound): Likewise. (equal_range): Likewise. (binary_search): Likewise. (inplace_merge): Likewise. (includes): Likewise. (next_permutation): Likewise. (prev_permutation): Likewise. (is_sorted_until): Likewise. (minmax_element): Likewise. (partial_sort): Likewise. (nth_element): Likewise. (sort): Likewise. (merge): Likewise. (stable_sort): Likewise. (set_union): Likewise. (set_intersection): Likewise. (set_difference): Likewise. (set_symmetric_difference): Likewise. (min_element): Likewise. (max_element): Likewise. * include/bits/stl_algobase.h (lower_bound): Likewise. (lexicographical_compare): Likewise. * include/bits/stl_heap.h (push_heap): Likewise. (pop_heap): Likewise. (make_heap): Likewise. (sort_heap): Likewise. (is_heap_until): Likewise. * testsuite/25_algorithms/lexicographical_compare/debug/ irreflexive_neg.cc: New. * testsuite/25_algorithms/lower_bound/debug/irreflexive.cc: New. * testsuite/25_algorithms/partial_sort_copy/debug/irreflexive_neg.cc: New. From-SVN: r227147
Diffstat (limited to 'libstdc++-v3/include/debug/functions.h')
-rw-r--r--libstdc++-v3/include/debug/functions.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/libstdc++-v3/include/debug/functions.h b/libstdc++-v3/include/debug/functions.h
index a9f234b..218092a 100644
--- a/libstdc++-v3/include/debug/functions.h
+++ b/libstdc++-v3/include/debug/functions.h
@@ -445,6 +445,49 @@ namespace __gnu_debug
return __first == __last;
}
+#if __cplusplus >= 201103L
+ struct _Irreflexive_checker
+ {
+ template<typename _It>
+ static typename std::iterator_traits<_It>::reference
+ __deref();
+
+ template<typename _It,
+ typename = decltype(__deref<_It>() < __deref<_It>())>
+ static bool
+ _S_is_valid(_It __it)
+ { return !(*__it < *__it); }
+
+ // Fallback method if operator doesn't exist.
+ template<typename... _Args>
+ static bool
+ _S_is_valid(_Args...)
+ { return true; }
+
+ template<typename _It, typename _Pred, typename
+ = decltype(std::declval<_Pred>()(__deref<_It>(), __deref<_It>()))>
+ static bool
+ _S_is_valid_pred(_It __it, _Pred __pred)
+ { return !__pred(*__it, *__it); }
+
+ // Fallback method if predicate can't be invoked.
+ template<typename... _Args>
+ static bool
+ _S_is_valid_pred(_Args...)
+ { return true; }
+ };
+
+ template<typename _Iterator>
+ inline bool
+ __is_irreflexive(_Iterator __it)
+ { return _Irreflexive_checker::_S_is_valid(__it); }
+
+ template<typename _Iterator, typename _Pred>
+ inline bool
+ __is_irreflexive_pred(_Iterator __it, _Pred __pred)
+ { return _Irreflexive_checker::_S_is_valid_pred(__it, __pred); }
+#endif
+
} // namespace __gnu_debug
#endif