diff options
author | Eric Fiselier <eric@efcs.ca> | 2016-07-19 23:27:18 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2016-07-19 23:27:18 +0000 |
commit | 331d21599dc6a1fbcb19155ae532fda7c3449b4f (patch) | |
tree | 0000f44c4c2e539ebfbf424445287b900f893f88 /libcxx/include/algorithm | |
parent | 7ab570ec3a229ff30aa8f0122d5df0e27eec1349 (diff) | |
download | bcm5719-llvm-331d21599dc6a1fbcb19155ae532fda7c3449b4f.tar.gz bcm5719-llvm-331d21599dc6a1fbcb19155ae532fda7c3449b4f.zip |
Add heterogeneous comparator support for __debug_less. Fixes PR17147.
llvm-svn: 276059
Diffstat (limited to 'libcxx/include/algorithm')
-rw-r--r-- | libcxx/include/algorithm | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm index 7a6db7abd26..25e95ac443a 100644 --- a/libcxx/include/algorithm +++ b/libcxx/include/algorithm @@ -749,14 +749,28 @@ struct __debug_less { _Compare __comp_; __debug_less(_Compare& __c) : __comp_(__c) {} + template <class _Tp, class _Up> bool operator()(const _Tp& __x, const _Up& __y) { bool __r = __comp_(__x, __y); if (__r) - _LIBCPP_ASSERT(!__comp_(__y, __x), "Comparator does not induce a strict weak ordering"); + __do_compare_assert(0, __y, __x); return __r; } + + template <class _LHS, class _RHS> + inline _LIBCPP_INLINE_VISIBILITY + decltype((void)_VSTD::declval<_Compare&>()( + _VSTD::declval<_LHS const&>(), _VSTD::declval<_RHS const&>())) + __do_compare_assert(int, _LHS const& __l, _RHS const& __r) { + _LIBCPP_ASSERT(!__comp_(__l, __r), + "Comparator does not induce a strict weak ordering"); + } + + template <class _LHS, class _RHS> + inline _LIBCPP_INLINE_VISIBILITY + void __do_compare_assert(long, _LHS const&, _RHS const&) {} }; #endif // _LIBCPP_DEBUG |