diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2019-08-20 20:51:16 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2019-08-20 20:51:16 +0000 |
commit | 1147845301c03308e3419b89c28c77bb6917fe04 (patch) | |
tree | 225f45e462607f9595a5e5f418a9533ab50e83bb /include/algorithm | |
parent | b7332b04df5d50c92640c74cfeb138ecb7e3f7ae (diff) | |
download | src-1147845301c03308e3419b89c28c77bb6917fe04.tar.gz src-1147845301c03308e3419b89c28c77bb6917fe04.zip |
Vendor import of stripped libc++ trunk r366426 (just before the release_90 branchvendor/libc++/libc++-trunk-r366426
Notes
Notes:
svn path=/vendor/libc++/dist/; revision=351284
svn path=/vendor/libc++/libc++-trunk-r366426/; revision=351285; tag=vendor/libc++/libc++-trunk-r366426
Diffstat (limited to 'include/algorithm')
-rw-r--r-- | include/algorithm | 459 |
1 files changed, 215 insertions, 244 deletions
diff --git a/include/algorithm b/include/algorithm index d102899f2dfc..0d7862675588 100644 --- a/include/algorithm +++ b/include/algorithm @@ -1,10 +1,9 @@ // -*- C++ -*- //===-------------------------- algorithm ---------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -781,11 +780,23 @@ __half_positive(_Tp __value) template <class _Compare> struct __debug_less { - _Compare __comp_; + _Compare &__comp_; + _LIBCPP_CONSTEXPR_AFTER_CXX17 __debug_less(_Compare& __c) : __comp_(__c) {} template <class _Tp, class _Up> - bool operator()(const _Tp& __x, const _Up& __y) + _LIBCPP_CONSTEXPR_AFTER_CXX17 + bool operator()(const _Tp& __x, const _Up& __y) + { + bool __r = __comp_(__x, __y); + if (__r) + __do_compare_assert(0, __y, __x); + return __r; + } + + template <class _Tp, class _Up> + _LIBCPP_CONSTEXPR_AFTER_CXX17 + bool operator()(_Tp& __x, _Up& __y) { bool __r = __comp_(__x, __y); if (__r) @@ -794,25 +805,39 @@ struct __debug_less } template <class _LHS, class _RHS> + _LIBCPP_CONSTEXPR_AFTER_CXX17 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) { + _VSTD::declval<_LHS &>(), _VSTD::declval<_RHS &>())) + __do_compare_assert(int, _LHS & __l, _RHS & __r) { _LIBCPP_ASSERT(!__comp_(__l, __r), "Comparator does not induce a strict weak ordering"); } template <class _LHS, class _RHS> + _LIBCPP_CONSTEXPR_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY - void __do_compare_assert(long, _LHS const&, _RHS const&) {} + void __do_compare_assert(long, _LHS &, _RHS &) {} }; -#endif // _LIBCPP_DEBUG +#endif // _LIBCPP_DEBUG + +template <class _Comp> +struct __comp_ref_type { + // Pass the comparator by lvalue reference. Or in debug mode, using a + // debugging wrapper that stores a reference. +#ifndef _LIBCPP_DEBUG + typedef typename add_lvalue_reference<_Comp>::type type; +#else + typedef __debug_less<_Comp> type; +#endif +}; // all_of template <class _InputIterator, class _Predicate> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { @@ -825,7 +850,8 @@ all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) // any_of template <class _InputIterator, class _Predicate> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { @@ -838,7 +864,8 @@ any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) // none_of template <class _InputIterator, class _Predicate> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool none_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { @@ -883,7 +910,8 @@ for_each_n(_InputIterator __first, _Size __orig_n, _Function __f) // find template <class _InputIterator, class _Tp> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _InputIterator find(_InputIterator __first, _InputIterator __last, const _Tp& __value_) { @@ -896,7 +924,8 @@ find(_InputIterator __first, _InputIterator __last, const _Tp& __value_) // find_if template <class _InputIterator, class _Predicate> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _InputIterator find_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) { @@ -909,7 +938,8 @@ find_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) // find_if_not template<class _InputIterator, class _Predicate> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _InputIterator find_if_not(_InputIterator __first, _InputIterator __last, _Predicate __pred) { @@ -1044,7 +1074,8 @@ __find_end(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, } template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1 find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred) @@ -1056,7 +1087,8 @@ find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, } template <class _ForwardIterator1, class _ForwardIterator2> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1 find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) @@ -1082,7 +1114,8 @@ __find_first_of_ce(_ForwardIterator1 __first1, _ForwardIterator1 __last1, template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1 find_first_of(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred) @@ -1091,7 +1124,8 @@ find_first_of(_ForwardIterator1 __first1, _ForwardIterator1 __last1, } template <class _ForwardIterator1, class _ForwardIterator2> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1 find_first_of(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) @@ -1104,7 +1138,8 @@ find_first_of(_ForwardIterator1 __first1, _ForwardIterator1 __last1, // adjacent_find template <class _ForwardIterator, class _BinaryPredicate> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator adjacent_find(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) { @@ -1122,7 +1157,8 @@ adjacent_find(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicat } template <class _ForwardIterator> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator adjacent_find(_ForwardIterator __first, _ForwardIterator __last) { @@ -1133,7 +1169,8 @@ adjacent_find(_ForwardIterator __first, _ForwardIterator __last) // count template <class _InputIterator, class _Tp> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 typename iterator_traits<_InputIterator>::difference_type count(_InputIterator __first, _InputIterator __last, const _Tp& __value_) { @@ -1147,7 +1184,8 @@ count(_InputIterator __first, _InputIterator __last, const _Tp& __value_) // count_if template <class _InputIterator, class _Predicate> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 typename iterator_traits<_InputIterator>::difference_type count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) { @@ -1161,7 +1199,8 @@ count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) // mismatch template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_InputIterator1, _InputIterator2> mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) @@ -1173,7 +1212,8 @@ mismatch(_InputIterator1 __first1, _InputIterator1 __last1, } template <class _InputIterator1, class _InputIterator2> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_InputIterator1, _InputIterator2> mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2) { @@ -1184,7 +1224,8 @@ mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __fi #if _LIBCPP_STD_VER > 11 template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_InputIterator1, _InputIterator2> mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, @@ -1197,7 +1238,8 @@ mismatch(_InputIterator1 __first1, _InputIterator1 __last1, } template <class _InputIterator1, class _InputIterator2> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_InputIterator1, _InputIterator2> mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) @@ -1211,7 +1253,8 @@ mismatch(_InputIterator1 __first1, _InputIterator1 __last1, // equal template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) { @@ -1222,7 +1265,8 @@ equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first } template <class _InputIterator1, class _InputIterator2> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2) { @@ -1260,7 +1304,8 @@ __equal(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, } template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _BinaryPredicate __pred ) @@ -1272,7 +1317,8 @@ equal(_InputIterator1 __first1, _InputIterator1 __last1, } template <class _InputIterator1, class _InputIterator2> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) @@ -1288,7 +1334,7 @@ equal(_InputIterator1 __first1, _InputIterator1 __last1, // is_permutation template<class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> -_LIBCPP_CONSTEXPR_AFTER_CXX17 bool +_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 bool is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _BinaryPredicate __pred) { @@ -1335,7 +1381,8 @@ is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, } template<class _ForwardIterator1, class _ForwardIterator2> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) @@ -1414,7 +1461,8 @@ __is_permutation(_RandomAccessIterator1 __first1, _RandomAccessIterator2 __last1 } template<class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2, @@ -1427,7 +1475,8 @@ is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, } template<class _ForwardIterator1, class _ForwardIterator2> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) @@ -1445,7 +1494,8 @@ is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, // __search is in <functional> template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred) @@ -1458,7 +1508,8 @@ search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, } template <class _ForwardIterator1, class _ForwardIterator2> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) @@ -1471,7 +1522,7 @@ search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, #if _LIBCPP_STD_VER > 14 template <class _ForwardIterator, class _Searcher> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator search(_ForwardIterator __f, _ForwardIterator __l, const _Searcher &__s) { return __s(__f, __l).first; } #endif @@ -1556,7 +1607,8 @@ __search_n(_RandomAccessIterator __first, _RandomAccessIterator __last, } template <class _ForwardIterator, class _Size, class _Tp, class _BinaryPredicate> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value_, _BinaryPredicate __pred) @@ -1567,7 +1619,8 @@ search_n(_ForwardIterator __first, _ForwardIterator __last, } template <class _ForwardIterator, class _Size, class _Tp> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value_) { @@ -1611,6 +1664,18 @@ __unwrap_iter(__wrap_iter<_Tp*> __i) return __i.base(); } +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG +typename enable_if +< + is_trivially_copy_assignable<_Tp>::value, + const _Tp* +>::type +__unwrap_iter(__wrap_iter<const _Tp*> __i) +{ + return __i.base(); +} + #else template <class _Tp> @@ -1984,7 +2049,7 @@ generate(_ForwardIterator __first, _ForwardIterator __last, _Generator __gen) // generate_n template <class _OutputIterator, class _Size, class _Generator> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator generate_n(_OutputIterator __first, _Size __orig_n, _Generator __gen) { @@ -1998,7 +2063,7 @@ generate_n(_OutputIterator __first, _Size __orig_n, _Generator __gen) // remove template <class _ForwardIterator, class _Tp> -_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator +_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_) { __first = _VSTD::find(__first, __last, __value_); @@ -2020,7 +2085,7 @@ remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_) // remove_if template <class _ForwardIterator, class _Predicate> -_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator +_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator remove_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { __first = _VSTD::find_if<_ForwardIterator, typename add_lvalue_reference<_Predicate>::type> @@ -2079,7 +2144,7 @@ remove_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __ // unique template <class _ForwardIterator, class _BinaryPredicate> -_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator +_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator unique(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) { __first = _VSTD::adjacent_find<_ForwardIterator, typename add_lvalue_reference<_BinaryPredicate>::type> @@ -2098,7 +2163,8 @@ unique(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pre } template <class _ForwardIterator> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator unique(_ForwardIterator __first, _ForwardIterator __last) { @@ -2421,7 +2487,8 @@ rotate_copy(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterato // min_element template <class _ForwardIterator, class _Compare> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { @@ -2438,7 +2505,8 @@ min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) } template <class _ForwardIterator> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator min_element(_ForwardIterator __first, _ForwardIterator __last) { @@ -2449,7 +2517,8 @@ min_element(_ForwardIterator __first, _ForwardIterator __last) // min template <class _Tp, class _Compare> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Tp& min(const _Tp& __a, const _Tp& __b, _Compare __comp) { @@ -2457,7 +2526,8 @@ min(const _Tp& __a, const _Tp& __b, _Compare __comp) } template <class _Tp> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Tp& min(const _Tp& __a, const _Tp& __b) { @@ -2467,7 +2537,8 @@ min(const _Tp& __a, const _Tp& __b) #ifndef _LIBCPP_CXX03_LANG template<class _Tp, class _Compare> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp min(initializer_list<_Tp> __t, _Compare __comp) { @@ -2475,7 +2546,8 @@ min(initializer_list<_Tp> __t, _Compare __comp) } template<class _Tp> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp min(initializer_list<_Tp> __t) { @@ -2487,7 +2559,8 @@ min(initializer_list<_Tp> __t) // max_element template <class _ForwardIterator, class _Compare> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { @@ -2505,7 +2578,8 @@ max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) template <class _ForwardIterator> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator max_element(_ForwardIterator __first, _ForwardIterator __last) { @@ -2516,7 +2590,8 @@ max_element(_ForwardIterator __first, _ForwardIterator __last) // max template <class _Tp, class _Compare> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Tp& max(const _Tp& __a, const _Tp& __b, _Compare __comp) { @@ -2524,7 +2599,8 @@ max(const _Tp& __a, const _Tp& __b, _Compare __comp) } template <class _Tp> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Tp& max(const _Tp& __a, const _Tp& __b) { @@ -2534,7 +2610,8 @@ max(const _Tp& __a, const _Tp& __b) #ifndef _LIBCPP_CXX03_LANG template<class _Tp, class _Compare> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp max(initializer_list<_Tp> __t, _Compare __comp) { @@ -2542,7 +2619,8 @@ max(initializer_list<_Tp> __t, _Compare __comp) } template<class _Tp> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp max(initializer_list<_Tp> __t) { @@ -2554,7 +2632,8 @@ max(initializer_list<_Tp> __t) #if _LIBCPP_STD_VER > 14 // clamp template<class _Tp, class _Compare> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const _Tp& clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi, _Compare __comp) { @@ -2564,7 +2643,8 @@ clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi, _Compare __comp) } template<class _Tp> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const _Tp& clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi) { @@ -2575,7 +2655,7 @@ clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi) // minmax_element template <class _ForwardIterator, class _Compare> -_LIBCPP_CONSTEXPR_AFTER_CXX11 +_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX11 std::pair<_ForwardIterator, _ForwardIterator> minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { @@ -2625,7 +2705,8 @@ minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __com } template <class _ForwardIterator> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 std::pair<_ForwardIterator, _ForwardIterator> minmax_element(_ForwardIterator __first, _ForwardIterator __last) { @@ -2636,7 +2717,8 @@ minmax_element(_ForwardIterator __first, _ForwardIterator __last) // minmax template<class _Tp, class _Compare> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 pair<const _Tp&, const _Tp&> minmax(const _Tp& __a, const _Tp& __b, _Compare __comp) { @@ -2645,7 +2727,8 @@ minmax(const _Tp& __a, const _Tp& __b, _Compare __comp) } template<class _Tp> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 pair<const _Tp&, const _Tp&> minmax(const _Tp& __a, const _Tp& __b) { @@ -2655,7 +2738,8 @@ minmax(const _Tp& __a, const _Tp& __b) #ifndef _LIBCPP_CXX03_LANG template<class _Tp, class _Compare> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 pair<_Tp, _Tp> minmax(initializer_list<_Tp> __t, _Compare __comp) { @@ -2692,7 +2776,8 @@ minmax(initializer_list<_Tp> __t, _Compare __comp) } template<class _Tp> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 pair<_Tp, _Tp> minmax(initializer_list<_Tp> __t) { @@ -2936,7 +3021,7 @@ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK typedef __independent_bits_engine<_URNG, _UIntType> _Eng; if (_Rp == 0) return static_cast<result_type>(_Eng(__g, _Dt)()); - size_t __w = _Dt - __clz(_Rp) - 1; + size_t __w = _Dt - __libcpp_clz(_Rp) - 1; if ((_Rp & (std::numeric_limits<_UIntType>::max() >> (_Dt - __w))) != 0) ++__w; _Eng __e(__g, __w); @@ -2990,7 +3075,7 @@ random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last) { _Dp __uid; __rs_default __g = __rs_get(); - for (--__last, --__d; __first < __last; ++__first, --__d) + for (--__last, (void) --__d; __first < __last; ++__first, (void) --__d) { difference_type __i = __uid(__g, _Pp(0, __d)); if (__i != difference_type(0)) @@ -3012,7 +3097,7 @@ random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last, difference_type __d = __last - __first; if (__d > 1) { - for (--__last; __first < __last; ++__first, --__d) + for (--__last; __first < __last; ++__first, (void) --__d) { difference_type __i = __rand(__d); if (__i != difference_type(0)) @@ -3096,11 +3181,7 @@ _SampleIterator sample(_PopulationIterator __first, template<class _RandomAccessIterator, class _UniformRandomNumberGenerator> void shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last, -#ifndef _LIBCPP_CXX03_LANG _UniformRandomNumberGenerator&& __g) -#else - _UniformRandomNumberGenerator& __g) -#endif { typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; typedef uniform_int_distribution<ptrdiff_t> _Dp; @@ -3119,7 +3200,7 @@ template<class _RandomAccessIterator, class _UniformRandomNumberGenerator> } template <class _InputIterator, class _Predicate> -_LIBCPP_CONSTEXPR_AFTER_CXX17 bool +_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 bool is_partitioned(_InputIterator __first, _InputIterator __last, _Predicate __pred) { for (; __first != __last; ++__first) @@ -3527,7 +3608,7 @@ stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate _ // is_sorted_until template <class _ForwardIterator, class _Compare> -_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator +_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { if (__first != __last) @@ -3544,7 +3625,8 @@ is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __co } template<class _ForwardIterator> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator is_sorted_until(_ForwardIterator __first, _ForwardIterator __last) { @@ -3554,7 +3636,8 @@ is_sorted_until(_ForwardIterator __first, _ForwardIterator __last) // is_sorted template <class _ForwardIterator, class _Compare> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool is_sorted(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { @@ -3562,7 +3645,8 @@ is_sorted(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) } template<class _ForwardIterator> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool is_sorted(_ForwardIterator __first, _ForwardIterator __last) { @@ -4009,14 +4093,8 @@ inline _LIBCPP_INLINE_VISIBILITY void sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { -#ifdef _LIBCPP_DEBUG - typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; - __debug_less<_Compare> __c(__comp); - __sort<_Comp_ref>(__first, __last, __c); -#else // _LIBCPP_DEBUG - typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; - __sort<_Comp_ref>(__first, __last, __comp); -#endif // _LIBCPP_DEBUG + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; + _VSTD::__sort<_Comp_ref>(__first, __last, _Comp_ref(__comp)); } template <class _RandomAccessIterator> @@ -4111,7 +4189,8 @@ __lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __va } template <class _ForwardIterator, class _Tp, class _Compare> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) { @@ -4120,7 +4199,8 @@ lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __valu } template <class _ForwardIterator, class _Tp> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_) { @@ -4153,7 +4233,8 @@ __upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __va } template <class _ForwardIterator, class _Tp, class _Compare> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) { @@ -4162,7 +4243,8 @@ upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __valu } template <class _ForwardIterator, class _Tp> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_) { @@ -4207,22 +4289,18 @@ __equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __va } template <class _ForwardIterator, class _Tp, class _Compare> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_ForwardIterator, _ForwardIterator> equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) { -#ifdef _LIBCPP_DEBUG - typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; - __debug_less<_Compare> __c(__comp); - return __equal_range<_Comp_ref>(__first, __last, __value_, __c); -#else // _LIBCPP_DEBUG - typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; return __equal_range<_Comp_ref>(__first, __last, __value_, __comp); -#endif // _LIBCPP_DEBUG } template <class _ForwardIterator, class _Tp> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_ForwardIterator, _ForwardIterator> equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_) { @@ -4242,22 +4320,18 @@ __binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __ } template <class _ForwardIterator, class _Tp, class _Compare> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) { -#ifdef _LIBCPP_DEBUG - typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; - __debug_less<_Compare> __c(__comp); - return __binary_search<_Comp_ref>(__first, __last, __value_, __c); -#else // _LIBCPP_DEBUG - typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; return __binary_search<_Comp_ref>(__first, __last, __value_, __comp); -#endif // _LIBCPP_DEBUG } template <class _ForwardIterator, class _Tp> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_) { @@ -4296,14 +4370,8 @@ _OutputIterator merge(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { -#ifdef _LIBCPP_DEBUG - typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; - __debug_less<_Compare> __c(__comp); - return _VSTD::__merge<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __c); -#else // _LIBCPP_DEBUG - typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; return _VSTD::__merge<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); -#endif // _LIBCPP_DEBUG } template <class _InputIterator1, class _InputIterator2, class _OutputIterator> @@ -4478,17 +4546,9 @@ inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _ difference_type __buf_size = _VSTD::min(__len1, __len2); pair<value_type*, ptrdiff_t> __buf = _VSTD::get_temporary_buffer<value_type>(__buf_size); unique_ptr<value_type, __return_temporary_buffer> __h(__buf.first); - -#ifdef _LIBCPP_DEBUG - typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; - __debug_less<_Compare> __c(__comp); - return _VSTD::__inplace_merge<_Comp_ref>(__first, __middle, __last, __c, __len1, __len2, - __buf.first, __buf.second); -#else // _LIBCPP_DEBUG - typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; return _VSTD::__inplace_merge<_Comp_ref>(__first, __middle, __last, __comp, __len1, __len2, __buf.first, __buf.second); -#endif // _LIBCPP_DEBUG } template <class _BidirectionalIterator> @@ -4690,14 +4750,8 @@ stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compar __buf = _VSTD::get_temporary_buffer<value_type>(__len); __h.reset(__buf.first); } -#ifdef _LIBCPP_DEBUG - typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; - __debug_less<_Compare> __c(__comp); - __stable_sort<_Comp_ref>(__first, __last, __c, __len, __buf.first, __buf.second); -#else // _LIBCPP_DEBUG - typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; __stable_sort<_Comp_ref>(__first, __last, __comp, __len, __buf.first, __buf.second); -#endif // _LIBCPP_DEBUG } template <class _RandomAccessIterator> @@ -4711,7 +4765,7 @@ stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last) // is_heap_until template <class _RandomAccessIterator, class _Compare> -_LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator +_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { typedef typename _VSTD::iterator_traits<_RandomAccessIterator>::difference_type difference_type; @@ -4738,7 +4792,8 @@ is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp } template<class _RandomAccessIterator> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last) { @@ -4748,7 +4803,8 @@ is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last) // is_heap template <class _RandomAccessIterator, class _Compare> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { @@ -4756,7 +4812,8 @@ is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __ } template<class _RandomAccessIterator> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) { @@ -4797,14 +4854,8 @@ inline _LIBCPP_INLINE_VISIBILITY void push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { -#ifdef _LIBCPP_DEBUG - typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; - __debug_less<_Compare> __c(__comp); - __sift_up<_Comp_ref>(__first, __last, __c, __last - __first); -#else // _LIBCPP_DEBUG - typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; __sift_up<_Comp_ref>(__first, __last, __comp, __last - __first); -#endif // _LIBCPP_DEBUG } template <class _RandomAccessIterator> @@ -4890,14 +4941,8 @@ inline _LIBCPP_INLINE_VISIBILITY void pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { -#ifdef _LIBCPP_DEBUG - typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; - __debug_less<_Compare> __c(__comp); - __pop_heap<_Comp_ref>(__first, __last, __c, __last - __first); -#else // _LIBCPP_DEBUG - typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; __pop_heap<_Comp_ref>(__first, __last, __comp, __last - __first); -#endif // _LIBCPP_DEBUG } template <class _RandomAccessIterator> @@ -4931,14 +4976,8 @@ inline _LIBCPP_INLINE_VISIBILITY void make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { -#ifdef _LIBCPP_DEBUG - typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; - __debug_less<_Compare> __c(__comp); - __make_heap<_Comp_ref>(__first, __last, __c); -#else // _LIBCPP_DEBUG - typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; __make_heap<_Comp_ref>(__first, __last, __comp); -#endif // _LIBCPP_DEBUG } template <class _RandomAccessIterator> @@ -4965,14 +5004,8 @@ inline _LIBCPP_INLINE_VISIBILITY void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { -#ifdef _LIBCPP_DEBUG - typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; - __debug_less<_Compare> __c(__comp); - __sort_heap<_Comp_ref>(__first, __last, __c); -#else // _LIBCPP_DEBUG - typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; __sort_heap<_Comp_ref>(__first, __last, __comp); -#endif // _LIBCPP_DEBUG } template <class _RandomAccessIterator> @@ -5009,14 +5042,8 @@ void partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last, _Compare __comp) { -#ifdef _LIBCPP_DEBUG - typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; - __debug_less<_Compare> __c(__comp); - __partial_sort<_Comp_ref>(__first, __middle, __last, __c); -#else // _LIBCPP_DEBUG - typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; __partial_sort<_Comp_ref>(__first, __middle, __last, __comp); -#endif // _LIBCPP_DEBUG } template <class _RandomAccessIterator> @@ -5059,14 +5086,8 @@ _RandomAccessIterator partial_sort_copy(_InputIterator __first, _InputIterator __last, _RandomAccessIterator __result_first, _RandomAccessIterator __result_last, _Compare __comp) { -#ifdef _LIBCPP_DEBUG - typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; - __debug_less<_Compare> __c(__comp); - return __partial_sort_copy<_Comp_ref>(__first, __last, __result_first, __result_last, __c); -#else // _LIBCPP_DEBUG - typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; return __partial_sort_copy<_Comp_ref>(__first, __last, __result_first, __result_last, __comp); -#endif // _LIBCPP_DEBUG } template <class _InputIterator, class _RandomAccessIterator> @@ -5273,14 +5294,8 @@ inline _LIBCPP_INLINE_VISIBILITY void nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, _Compare __comp) { -#ifdef _LIBCPP_DEBUG - typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; - __debug_less<_Compare> __c(__comp); - __nth_element<_Comp_ref>(__first, __nth, __last, __c); -#else // _LIBCPP_DEBUG - typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; __nth_element<_Comp_ref>(__first, __nth, __last, __comp); -#endif // _LIBCPP_DEBUG } template <class _RandomAccessIterator> @@ -5309,23 +5324,19 @@ __includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __ } template <class _InputIterator1, class _InputIterator2, class _Compare> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp) { -#ifdef _LIBCPP_DEBUG - typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; - __debug_less<_Compare> __c(__comp); - return __includes<_Comp_ref>(__first1, __last1, __first2, __last2, __c); -#else // _LIBCPP_DEBUG - typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; return __includes<_Comp_ref>(__first1, __last1, __first2, __last2, __comp); -#endif // _LIBCPP_DEBUG } template <class _InputIterator1, class _InputIterator2> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) { @@ -5367,14 +5378,8 @@ _OutputIterator set_union(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { -#ifdef _LIBCPP_DEBUG - typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; - __debug_less<_Compare> __c(__comp); - return __set_union<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __c); -#else // _LIBCPP_DEBUG - typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; return __set_union<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); -#endif // _LIBCPP_DEBUG } template <class _InputIterator1, class _InputIterator2, class _OutputIterator> @@ -5419,14 +5424,8 @@ _OutputIterator set_intersection(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { -#ifdef _LIBCPP_DEBUG - typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; - __debug_less<_Compare> __c(__comp); - return __set_intersection<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __c); -#else // _LIBCPP_DEBUG - typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; return __set_intersection<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); -#endif // _LIBCPP_DEBUG } template <class _InputIterator1, class _InputIterator2, class _OutputIterator> @@ -5473,14 +5472,8 @@ _OutputIterator set_difference(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { -#ifdef _LIBCPP_DEBUG - typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; - __debug_less<_Compare> __c(__comp); - return __set_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __c); -#else // _LIBCPP_DEBUG - typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; return __set_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); -#endif // _LIBCPP_DEBUG } template <class _InputIterator1, class _InputIterator2, class _OutputIterator> @@ -5532,14 +5525,8 @@ _OutputIterator set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { -#ifdef _LIBCPP_DEBUG - typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; - __debug_less<_Compare> __c(__comp); - return __set_symmetric_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __c); -#else // _LIBCPP_DEBUG - typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; return __set_symmetric_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); -#endif // _LIBCPP_DEBUG } template <class _InputIterator1, class _InputIterator2, class _OutputIterator> @@ -5571,23 +5558,19 @@ __lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1, } template <class _InputIterator1, class _InputIterator2, class _Compare> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp) { -#ifdef _LIBCPP_DEBUG - typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; - __debug_less<_Compare> __c(__comp); - return __lexicographical_compare<_Comp_ref>(__first1, __last1, __first2, __last2, __c); -#else // _LIBCPP_DEBUG - typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; return __lexicographical_compare<_Comp_ref>(__first1, __last1, __first2, __last2, __comp); -#endif // _LIBCPP_DEBUG } template <class _InputIterator1, class _InputIterator2> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) @@ -5631,14 +5614,8 @@ inline _LIBCPP_INLINE_VISIBILITY bool next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) { -#ifdef _LIBCPP_DEBUG - typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; - __debug_less<_Compare> __c(__comp); - return __next_permutation<_Comp_ref>(__first, __last, __c); -#else // _LIBCPP_DEBUG - typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; return __next_permutation<_Comp_ref>(__first, __last, __comp); -#endif // _LIBCPP_DEBUG } template <class _BidirectionalIterator> @@ -5684,14 +5661,8 @@ inline _LIBCPP_INLINE_VISIBILITY bool prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) { -#ifdef _LIBCPP_DEBUG - typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; - __debug_less<_Compare> __c(__comp); - return __prev_permutation<_Comp_ref>(__first, __last, __c); -#else // _LIBCPP_DEBUG - typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; return __prev_permutation<_Comp_ref>(__first, __last, __comp); -#endif // _LIBCPP_DEBUG } template <class _BidirectionalIterator> |