From: Nikolas Klauser Date: Tue, 1 Nov 2022 19:06:11 +0000 (+0100) Subject: [libc++] Add [[nodiscard]] extensions to ranges algorithms X-Git-Tag: upstream/17.0.6~28435 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=660b243120bcefdc108471c724fec382b062ad62;p=platform%2Fupstream%2Fllvm.git [libc++] Add [[nodiscard]] extensions to ranges algorithms This mirrors what we have done in the classic algorithms Reviewed By: ldionne, #libc Spies: libcxx-commits Differential Revision: https://reviews.llvm.org/D137186 --- diff --git a/libcxx/docs/UsingLibcxx.rst b/libcxx/docs/UsingLibcxx.rst index 59a1e4b..e6425d8 100644 --- a/libcxx/docs/UsingLibcxx.rst +++ b/libcxx/docs/UsingLibcxx.rst @@ -393,6 +393,44 @@ which no dialect declares as such (See the second form described above). * ``search`` * ``unique`` * ``upper_bound`` +* ``ranges::adjacent_find`` +* ``ranges::all_of`` +* ``ranges::any_of`` +* ``ranges::binary_search`` +* ``ranges::clamp`` +* ``ranges::count_if`` +* ``ranges::count`` +* ``ranges::equal_range`` +* ``ranges::equal`` +* ``ranges::find_end`` +* ``ranges::find_first_of`` +* ``ranges::find_if_not`` +* ``ranges::find_if`` +* ``ranges::find`` +* ``ranges::get_temporary_buffer`` +* ``ranges::includes`` +* ``ranges::is_heap_until`` +* ``ranges::is_heap`` +* ``ranges::is_partitioned`` +* ``ranges::is_permutation`` +* ``ranges::is_sorted_until`` +* ``ranges::is_sorted`` +* ``ranges::lexicographical_compare`` +* ``ranges::lower_bound`` +* ``ranges::max_element`` +* ``ranges::max`` +* ``ranges::min_element`` +* ``ranges::min`` +* ``ranges::minmax_element`` +* ``ranges::minmax`` +* ``ranges::mismatch`` +* ``ranges::none_of`` +* ``ranges::remove_if`` +* ``ranges::remove`` +* ``ranges::search_n`` +* ``ranges::search`` +* ``ranges::unique`` +* ``ranges::upper_bound`` * ``lock_guard``'s constructors * ``as_const`` * ``bit_cast`` diff --git a/libcxx/include/__algorithm/ranges_adjacent_find.h b/libcxx/include/__algorithm/ranges_adjacent_find.h index 4ed306b..d338d13 100644 --- a/libcxx/include/__algorithm/ranges_adjacent_find.h +++ b/libcxx/include/__algorithm/ranges_adjacent_find.h @@ -50,7 +50,7 @@ struct __fn { template _Sent, class _Proj = identity, indirect_binary_predicate, projected<_Iter, _Proj>> _Pred = ranges::equal_to> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Iter operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const { return __adjacent_find_impl(std::move(__first), std::move(__last), __pred, __proj); } @@ -59,7 +59,7 @@ struct __fn { class _Proj = identity, indirect_binary_predicate, _Proj>, projected, _Proj>> _Pred = ranges::equal_to> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range> operator()(_Range&& __range, _Pred __pred = {}, _Proj __proj = {}) const { return __adjacent_find_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); } diff --git a/libcxx/include/__algorithm/ranges_all_of.h b/libcxx/include/__algorithm/ranges_all_of.h index f73d069..e45c4e5 100644 --- a/libcxx/include/__algorithm/ranges_all_of.h +++ b/libcxx/include/__algorithm/ranges_all_of.h @@ -42,14 +42,14 @@ struct __fn { template _Sent, class _Proj = identity, indirect_unary_predicate> _Pred> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const { return __all_of_impl(std::move(__first), std::move(__last), __pred, __proj); } template , _Proj>> _Pred> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const { return __all_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); } diff --git a/libcxx/include/__algorithm/ranges_any_of.h b/libcxx/include/__algorithm/ranges_any_of.h index 53627ed..e7d1e72 100644 --- a/libcxx/include/__algorithm/ranges_any_of.h +++ b/libcxx/include/__algorithm/ranges_any_of.h @@ -42,14 +42,14 @@ struct __fn { template _Sent, class _Proj = identity, indirect_unary_predicate> _Pred> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const { return __any_of_impl(std::move(__first), std::move(__last), __pred, __proj); } template , _Proj>> _Pred> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const { return __any_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); } diff --git a/libcxx/include/__algorithm/ranges_binary_search.h b/libcxx/include/__algorithm/ranges_binary_search.h index 39a9a02..b2a8977 100644 --- a/libcxx/include/__algorithm/ranges_binary_search.h +++ b/libcxx/include/__algorithm/ranges_binary_search.h @@ -33,7 +33,7 @@ namespace __binary_search { struct __fn { template _Sent, class _Type, class _Proj = identity, indirect_strict_weak_order> _Comp = ranges::less> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Iter __first, _Sent __last, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const { auto __ret = std::__lower_bound_impl<_RangeAlgPolicy>(__first, __last, __value, __comp, __proj); return __ret != __last && !std::invoke(__comp, __value, std::invoke(__proj, *__first)); @@ -41,7 +41,7 @@ struct __fn { template , _Proj>> _Comp = ranges::less> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Range&& __r, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const { auto __first = ranges::begin(__r); auto __last = ranges::end(__r); diff --git a/libcxx/include/__algorithm/ranges_clamp.h b/libcxx/include/__algorithm/ranges_clamp.h index 1bb3a5a..09a97fc 100644 --- a/libcxx/include/__algorithm/ranges_clamp.h +++ b/libcxx/include/__algorithm/ranges_clamp.h @@ -33,7 +33,7 @@ struct __fn { template > _Comp = ranges::less> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr const _Type& operator()(const _Type& __value, const _Type& __low, const _Type& __high, diff --git a/libcxx/include/__algorithm/ranges_count.h b/libcxx/include/__algorithm/ranges_count.h index f790c99..527dd06 100644 --- a/libcxx/include/__algorithm/ranges_count.h +++ b/libcxx/include/__algorithm/ranges_count.h @@ -34,7 +34,7 @@ namespace __count { struct __fn { template _Sent, class _Type, class _Proj = identity> requires indirect_binary_predicate, const _Type*> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Iter> operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = {}) const { auto __pred = [&](auto&& __e) { return __e == __value; }; return ranges::__count_if_impl(std::move(__first), std::move(__last), __pred, __proj); @@ -42,7 +42,7 @@ struct __fn { template requires indirect_binary_predicate, _Proj>, const _Type*> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr range_difference_t<_Range> operator()(_Range&& __r, const _Type& __value, _Proj __proj = {}) const { auto __pred = [&](auto&& __e) { return __e == __value; }; return ranges::__count_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj); diff --git a/libcxx/include/__algorithm/ranges_count_if.h b/libcxx/include/__algorithm/ranges_count_if.h index 8cf1d02..931618b 100644 --- a/libcxx/include/__algorithm/ranges_count_if.h +++ b/libcxx/include/__algorithm/ranges_count_if.h @@ -46,14 +46,14 @@ namespace __count_if { struct __fn { template _Sent, class _Proj = identity, indirect_unary_predicate> _Predicate> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Iter> operator()(_Iter __first, _Sent __last, _Predicate __pred, _Proj __proj = {}) const { return ranges::__count_if_impl(std::move(__first), std::move(__last), __pred, __proj); } template , _Proj>> _Predicate> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr range_difference_t<_Range> operator()(_Range&& __r, _Predicate __pred, _Proj __proj = {}) const { return ranges::__count_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj); } diff --git a/libcxx/include/__algorithm/ranges_equal.h b/libcxx/include/__algorithm/ranges_equal.h index f7424ff..3c417f0 100644 --- a/libcxx/include/__algorithm/ranges_equal.h +++ b/libcxx/include/__algorithm/ranges_equal.h @@ -60,7 +60,7 @@ public: class _Proj1 = identity, class _Proj2 = identity> requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2, _Pred __pred = {}, @@ -83,7 +83,7 @@ public: class _Proj1 = identity, class _Proj2 = identity> requires indirectly_comparable, iterator_t<_Range2>, _Pred, _Proj1, _Proj2> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, diff --git a/libcxx/include/__algorithm/ranges_equal_range.h b/libcxx/include/__algorithm/ranges_equal_range.h index efe5b2f..94dc058 100644 --- a/libcxx/include/__algorithm/ranges_equal_range.h +++ b/libcxx/include/__algorithm/ranges_equal_range.h @@ -44,7 +44,7 @@ struct __fn { class _Tp, class _Proj = identity, indirect_strict_weak_order> _Comp = ranges::less> - _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter> + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter> operator()(_Iter __first, _Sent __last, const _Tp& __value, _Comp __comp = {}, _Proj __proj = {}) const { auto __ret = std::__equal_range<_RangeAlgPolicy>( std::move(__first), std::move(__last), __value, __comp, __proj); @@ -56,7 +56,7 @@ struct __fn { class _Tp, class _Proj = identity, indirect_strict_weak_order, _Proj>> _Comp = ranges::less> - _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range> + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range> operator()(_Range&& __range, const _Tp& __value, _Comp __comp = {}, _Proj __proj = {}) const { auto __ret = std::__equal_range<_RangeAlgPolicy>( ranges::begin(__range), ranges::end(__range), __value, __comp, __proj); diff --git a/libcxx/include/__algorithm/ranges_find.h b/libcxx/include/__algorithm/ranges_find.h index 1681eb1..580c2a1 100644 --- a/libcxx/include/__algorithm/ranges_find.h +++ b/libcxx/include/__algorithm/ranges_find.h @@ -35,7 +35,7 @@ namespace __find { struct __fn { template _Sp, class _Tp, class _Proj = identity> requires indirect_binary_predicate, const _Tp*> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __first, _Sp __last, const _Tp& __value, _Proj __proj = {}) const { auto __pred = [&](auto&& __e) { return std::forward(__e) == __value; }; return ranges::__find_if_impl(std::move(__first), std::move(__last), __pred, __proj); @@ -43,7 +43,7 @@ struct __fn { template requires indirect_binary_predicate, _Proj>, const _Tp*> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Rp> operator()(_Rp&& __r, const _Tp& __value, _Proj __proj = {}) const { auto __pred = [&](auto&& __e) { return std::forward(__e) == __value; }; return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj); diff --git a/libcxx/include/__algorithm/ranges_find_end.h b/libcxx/include/__algorithm/ranges_find_end.h index df89100..ea36f4d 100644 --- a/libcxx/include/__algorithm/ranges_find_end.h +++ b/libcxx/include/__algorithm/ranges_find_end.h @@ -40,7 +40,7 @@ struct __fn { class _Proj1 = identity, class _Proj2 = identity> requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter1> operator()(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2, _Pred __pred = {}, @@ -65,7 +65,7 @@ struct __fn { class _Proj1 = identity, class _Proj2 = identity> requires indirectly_comparable, iterator_t<_Range2>, _Pred, _Proj1, _Proj2> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range1> operator()(_Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, diff --git a/libcxx/include/__algorithm/ranges_find_first_of.h b/libcxx/include/__algorithm/ranges_find_first_of.h index 44221c1..9d66e75 100644 --- a/libcxx/include/__algorithm/ranges_find_first_of.h +++ b/libcxx/include/__algorithm/ranges_find_first_of.h @@ -54,7 +54,7 @@ struct __fn { class _Proj1 = identity, class _Proj2 = identity> requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Iter1 operator()(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2, _Pred __pred = {}, @@ -73,7 +73,7 @@ struct __fn { class _Proj1 = identity, class _Proj2 = identity> requires indirectly_comparable, iterator_t<_Range2>, _Pred, _Proj1, _Proj2> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range1> operator()(_Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, diff --git a/libcxx/include/__algorithm/ranges_find_if.h b/libcxx/include/__algorithm/ranges_find_if.h index b3f450e..45ce6e46 100644 --- a/libcxx/include/__algorithm/ranges_find_if.h +++ b/libcxx/include/__algorithm/ranges_find_if.h @@ -45,14 +45,14 @@ struct __fn { template _Sp, class _Proj = identity, indirect_unary_predicate> _Pred> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __first, _Sp __last, _Pred __pred, _Proj __proj = {}) const { return ranges::__find_if_impl(std::move(__first), std::move(__last), __pred, __proj); } template , _Proj>> _Pred> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Rp> operator()(_Rp&& __r, _Pred __pred, _Proj __proj = {}) const { return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj); } diff --git a/libcxx/include/__algorithm/ranges_find_if_not.h b/libcxx/include/__algorithm/ranges_find_if_not.h index ffd42ed..3dd1213 100644 --- a/libcxx/include/__algorithm/ranges_find_if_not.h +++ b/libcxx/include/__algorithm/ranges_find_if_not.h @@ -35,7 +35,7 @@ namespace __find_if_not { struct __fn { template _Sp, class _Proj = identity, indirect_unary_predicate> _Pred> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __first, _Sp __last, _Pred __pred, _Proj __proj = {}) const { auto __pred2 = [&](auto&& __e) { return !std::invoke(__pred, std::forward(__e)); }; return ranges::__find_if_impl(std::move(__first), std::move(__last), __pred2, __proj); @@ -43,7 +43,7 @@ struct __fn { template , _Proj>> _Pred> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Rp> operator()(_Rp&& __r, _Pred __pred, _Proj __proj = {}) const { auto __pred2 = [&](auto&& __e) { return !std::invoke(__pred, std::forward(__e)); }; return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred2, __proj); diff --git a/libcxx/include/__algorithm/ranges_includes.h b/libcxx/include/__algorithm/ranges_includes.h index 26cd8d8..8438117 100644 --- a/libcxx/include/__algorithm/ranges_includes.h +++ b/libcxx/include/__algorithm/ranges_includes.h @@ -43,7 +43,7 @@ struct __fn { class _Proj1 = identity, class _Proj2 = identity, indirect_strict_weak_order, projected<_Iter2, _Proj2>> _Comp = ranges::less> - _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( _Iter1 __first1, _Sent1 __last1, _Iter2 __first2, @@ -68,7 +68,7 @@ struct __fn { class _Proj2 = identity, indirect_strict_weak_order, _Proj1>, projected, _Proj2>> _Comp = ranges::less> - _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( _Range1&& __range1, _Range2&& __range2, _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { return std::__includes( ranges::begin(__range1), diff --git a/libcxx/include/__algorithm/ranges_is_heap.h b/libcxx/include/__algorithm/ranges_is_heap.h index 6b11931..a16c075 100644 --- a/libcxx/include/__algorithm/ranges_is_heap.h +++ b/libcxx/include/__algorithm/ranges_is_heap.h @@ -47,14 +47,14 @@ struct __fn { template _Sent, class _Proj = identity, indirect_strict_weak_order> _Comp = ranges::less> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const { return __is_heap_fn_impl(std::move(__first), std::move(__last), __comp, __proj); } template , _Proj>> _Comp = ranges::less> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const { return __is_heap_fn_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj); } diff --git a/libcxx/include/__algorithm/ranges_is_heap_until.h b/libcxx/include/__algorithm/ranges_is_heap_until.h index 2ca0d06..8c8dac5 100644 --- a/libcxx/include/__algorithm/ranges_is_heap_until.h +++ b/libcxx/include/__algorithm/ranges_is_heap_until.h @@ -47,14 +47,14 @@ struct __fn { template _Sent, class _Proj = identity, indirect_strict_weak_order> _Comp = ranges::less> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Iter operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const { return __is_heap_until_fn_impl(std::move(__first), std::move(__last), __comp, __proj); } template , _Proj>> _Comp = ranges::less> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range> operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const { return __is_heap_until_fn_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj); } diff --git a/libcxx/include/__algorithm/ranges_is_partitioned.h b/libcxx/include/__algorithm/ranges_is_partitioned.h index ce56378..b903953 100644 --- a/libcxx/include/__algorithm/ranges_is_partitioned.h +++ b/libcxx/include/__algorithm/ranges_is_partitioned.h @@ -54,7 +54,7 @@ struct __fn { template _Sent, class _Proj = identity, indirect_unary_predicate> _Pred> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const { return __is_parititioned_impl(std::move(__first), std::move(__last), __pred, __proj); } @@ -62,7 +62,7 @@ struct __fn { template , _Proj>> _Pred> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const { return __is_parititioned_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); } diff --git a/libcxx/include/__algorithm/ranges_is_permutation.h b/libcxx/include/__algorithm/ranges_is_permutation.h index afee6b5..b617500 100644 --- a/libcxx/include/__algorithm/ranges_is_permutation.h +++ b/libcxx/include/__algorithm/ranges_is_permutation.h @@ -49,7 +49,7 @@ struct __fn { class _Proj2 = identity, indirect_equivalence_relation, projected<_Iter2, _Proj2>> _Pred = ranges::equal_to> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { return __is_permutation_func_impl( @@ -62,7 +62,7 @@ struct __fn { class _Proj1 = identity, class _Proj2 = identity, indirect_equivalence_relation, _Proj1>, projected, _Proj2>> _Pred = ranges::equal_to> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { if constexpr (sized_range<_Range1> && sized_range<_Range2>) { diff --git a/libcxx/include/__algorithm/ranges_is_sorted.h b/libcxx/include/__algorithm/ranges_is_sorted.h index e355056..ce3032f 100644 --- a/libcxx/include/__algorithm/ranges_is_sorted.h +++ b/libcxx/include/__algorithm/ranges_is_sorted.h @@ -33,7 +33,7 @@ struct __fn { template _Sent, class _Proj = identity, indirect_strict_weak_order> _Comp = ranges::less> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const { return ranges::__is_sorted_until_impl(std::move(__first), __last, __comp, __proj) == __last; } @@ -41,7 +41,7 @@ struct __fn { template , _Proj>> _Comp = ranges::less> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const { auto __last = ranges::end(__range); return ranges::__is_sorted_until_impl(ranges::begin(__range), __last, __comp, __proj) == __last; diff --git a/libcxx/include/__algorithm/ranges_is_sorted_until.h b/libcxx/include/__algorithm/ranges_is_sorted_until.h index 47e98b8..17fc42e 100644 --- a/libcxx/include/__algorithm/ranges_is_sorted_until.h +++ b/libcxx/include/__algorithm/ranges_is_sorted_until.h @@ -49,7 +49,7 @@ struct __fn { template _Sent, class _Proj = identity, indirect_strict_weak_order> _Comp = ranges::less> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Iter operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const { return ranges::__is_sorted_until_impl(std::move(__first), std::move(__last), __comp, __proj); } @@ -57,7 +57,7 @@ struct __fn { template , _Proj>> _Comp = ranges::less> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range> operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const { return ranges::__is_sorted_until_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj); } diff --git a/libcxx/include/__algorithm/ranges_lexicographical_compare.h b/libcxx/include/__algorithm/ranges_lexicographical_compare.h index eab7bbe..2972e32 100644 --- a/libcxx/include/__algorithm/ranges_lexicographical_compare.h +++ b/libcxx/include/__algorithm/ranges_lexicographical_compare.h @@ -55,7 +55,7 @@ struct __fn { class _Proj1 = identity, class _Proj2 = identity, indirect_strict_weak_order, projected<_Iter2, _Proj2>> _Comp = ranges::less> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2, _Comp __comp = {}, @@ -74,7 +74,7 @@ struct __fn { class _Proj2 = identity, indirect_strict_weak_order, _Proj1>, projected, _Proj2>> _Comp = ranges::less> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Range1&& __range1, _Range2&& __range2, _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { return __lexicographical_compare_impl(ranges::begin(__range1), ranges::end(__range1), ranges::begin(__range2), ranges::end(__range2), diff --git a/libcxx/include/__algorithm/ranges_lower_bound.h b/libcxx/include/__algorithm/ranges_lower_bound.h index abcbe82..78cbb6d 100644 --- a/libcxx/include/__algorithm/ranges_lower_bound.h +++ b/libcxx/include/__algorithm/ranges_lower_bound.h @@ -37,14 +37,14 @@ namespace __lower_bound { struct __fn { template _Sent, class _Type, class _Proj = identity, indirect_strict_weak_order> _Comp = ranges::less> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Iter operator()(_Iter __first, _Sent __last, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const { return std::__lower_bound_impl<_RangeAlgPolicy>(__first, __last, __value, __comp, __proj); } template , _Proj>> _Comp = ranges::less> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range> operator()(_Range&& __r, const _Type& __value, _Comp __comp = {}, diff --git a/libcxx/include/__algorithm/ranges_max.h b/libcxx/include/__algorithm/ranges_max.h index f027faa..55aef99 100644 --- a/libcxx/include/__algorithm/ranges_max.h +++ b/libcxx/include/__algorithm/ranges_max.h @@ -39,14 +39,14 @@ namespace __max { struct __fn { template > _Comp = ranges::less> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& operator()(const _Tp& __a, const _Tp& __b, _Comp __comp = {}, _Proj __proj = {}) const { return std::invoke(__comp, std::invoke(__proj, __a), std::invoke(__proj, __b)) ? __b : __a; } template > _Comp = ranges::less> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Tp operator()(initializer_list<_Tp> __il, _Comp __comp = {}, _Proj __proj = {}) const { _LIBCPP_ASSERT(__il.begin() != __il.end(), "initializer_list must contain at least one element"); @@ -57,7 +57,7 @@ struct __fn { template , _Proj>> _Comp = ranges::less> requires indirectly_copyable_storable, range_value_t<_Rp>*> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr range_value_t<_Rp> operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const { auto __first = ranges::begin(__r); auto __last = ranges::end(__r); diff --git a/libcxx/include/__algorithm/ranges_max_element.h b/libcxx/include/__algorithm/ranges_max_element.h index d4c3242..490f320 100644 --- a/libcxx/include/__algorithm/ranges_max_element.h +++ b/libcxx/include/__algorithm/ranges_max_element.h @@ -33,7 +33,7 @@ namespace __max_element { struct __fn { template _Sp, class _Proj = identity, indirect_strict_weak_order> _Comp = ranges::less> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const { auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) { return std::invoke(__comp, __rhs, __lhs); }; return ranges::__min_element_impl(__first, __last, __comp_lhs_rhs_swapped, __proj); @@ -41,7 +41,7 @@ struct __fn { template , _Proj>> _Comp = ranges::less> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Rp> operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const { auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) { return std::invoke(__comp, __rhs, __lhs); }; return ranges::__min_element_impl(ranges::begin(__r), ranges::end(__r), __comp_lhs_rhs_swapped, __proj); diff --git a/libcxx/include/__algorithm/ranges_min.h b/libcxx/include/__algorithm/ranges_min.h index 8152a41..0e31f57 100644 --- a/libcxx/include/__algorithm/ranges_min.h +++ b/libcxx/include/__algorithm/ranges_min.h @@ -38,14 +38,14 @@ namespace __min { struct __fn { template > _Comp = ranges::less> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& operator()(const _Tp& __a, const _Tp& __b, _Comp __comp = {}, _Proj __proj = {}) const { return std::invoke(__comp, std::invoke(__proj, __b), std::invoke(__proj, __a)) ? __b : __a; } template > _Comp = ranges::less> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Tp operator()(initializer_list<_Tp> __il, _Comp __comp = {}, _Proj __proj = {}) const { _LIBCPP_ASSERT(__il.begin() != __il.end(), "initializer_list must contain at least one element"); return *ranges::__min_element_impl(__il.begin(), __il.end(), __comp, __proj); @@ -54,7 +54,7 @@ struct __fn { template , _Proj>> _Comp = ranges::less> requires indirectly_copyable_storable, range_value_t<_Rp>*> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr range_value_t<_Rp> operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const { auto __first = ranges::begin(__r); auto __last = ranges::end(__r); diff --git a/libcxx/include/__algorithm/ranges_min_element.h b/libcxx/include/__algorithm/ranges_min_element.h index 66d6499..1751874 100644 --- a/libcxx/include/__algorithm/ranges_min_element.h +++ b/libcxx/include/__algorithm/ranges_min_element.h @@ -48,14 +48,14 @@ namespace __min_element { struct __fn { template _Sp, class _Proj = identity, indirect_strict_weak_order> _Comp = ranges::less> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const { return ranges::__min_element_impl(__first, __last, __comp, __proj); } template , _Proj>> _Comp = ranges::less> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Rp> operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const { return ranges::__min_element_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj); } diff --git a/libcxx/include/__algorithm/ranges_minmax.h b/libcxx/include/__algorithm/ranges_minmax.h index 377fe9b..f82e005 100644 --- a/libcxx/include/__algorithm/ranges_minmax.h +++ b/libcxx/include/__algorithm/ranges_minmax.h @@ -45,7 +45,7 @@ namespace __minmax { struct __fn { template > _Comp = ranges::less> - _LIBCPP_HIDE_FROM_ABI constexpr ranges::minmax_result + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr ranges::minmax_result operator()(const _Type& __a, const _Type& __b, _Comp __comp = {}, _Proj __proj = {}) const { if (std::invoke(__comp, std::invoke(__proj, __b), std::invoke(__proj, __a))) return {__b, __a}; @@ -54,7 +54,7 @@ struct __fn { template > _Comp = ranges::less> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr ranges::minmax_result<_Type> operator()(initializer_list<_Type> __il, _Comp __comp = {}, _Proj __proj = {}) const { _LIBCPP_ASSERT(__il.begin() != __il.end(), "initializer_list has to contain at least one element"); auto __iters = std::__minmax_element_impl(__il.begin(), __il.end(), __comp, __proj); @@ -64,7 +64,7 @@ struct __fn { template , _Proj>> _Comp = ranges::less> requires indirectly_copyable_storable, range_value_t<_Range>*> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr ranges::minmax_result> operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const { auto __first = ranges::begin(__r); auto __last = ranges::end(__r); diff --git a/libcxx/include/__algorithm/ranges_minmax_element.h b/libcxx/include/__algorithm/ranges_minmax_element.h index 9d1093b..6699f96 100644 --- a/libcxx/include/__algorithm/ranges_minmax_element.h +++ b/libcxx/include/__algorithm/ranges_minmax_element.h @@ -42,7 +42,7 @@ namespace __minmax_element { struct __fn { template _Sp, class _Proj = identity, indirect_strict_weak_order> _Comp = ranges::less> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr ranges::minmax_element_result<_Ip> operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const { auto __ret = std::__minmax_element_impl(std::move(__first), std::move(__last), __comp, __proj); return {__ret.first, __ret.second}; @@ -50,7 +50,7 @@ struct __fn { template , _Proj>> _Comp = ranges::less> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr ranges::minmax_element_result> operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const { auto __ret = std::__minmax_element_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj); diff --git a/libcxx/include/__algorithm/ranges_mismatch.h b/libcxx/include/__algorithm/ranges_mismatch.h index 4775daf..4fd0517 100644 --- a/libcxx/include/__algorithm/ranges_mismatch.h +++ b/libcxx/include/__algorithm/ranges_mismatch.h @@ -55,7 +55,7 @@ struct __fn { input_iterator _I2, sentinel_for<_I2> _S2, class _Pred = ranges::equal_to, class _Proj1 = identity, class _Proj2 = identity> requires indirectly_comparable<_I1, _I2, _Pred, _Proj1, _Proj2> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr mismatch_result<_I1, _I2> operator()(_I1 __first1, _S1 __last1, _I2 __first2, _S2 __last2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { return __go(std::move(__first1), __last1, std::move(__first2), __last2, __pred, __proj1, __proj2); @@ -64,7 +64,7 @@ struct __fn { template requires indirectly_comparable, iterator_t<_R2>, _Pred, _Proj1, _Proj2> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr mismatch_result, borrowed_iterator_t<_R2>> operator()(_R1&& __r1, _R2&& __r2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { return __go(ranges::begin(__r1), ranges::end(__r1), ranges::begin(__r2), ranges::end(__r2), diff --git a/libcxx/include/__algorithm/ranges_none_of.h b/libcxx/include/__algorithm/ranges_none_of.h index d93b630..b39e570 100644 --- a/libcxx/include/__algorithm/ranges_none_of.h +++ b/libcxx/include/__algorithm/ranges_none_of.h @@ -42,14 +42,14 @@ struct __fn { template _Sent, class _Proj = identity, indirect_unary_predicate> _Pred> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const { return __none_of_impl(std::move(__first), std::move(__last), __pred, __proj); } template , _Proj>> _Pred> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const { return __none_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); } diff --git a/libcxx/include/__algorithm/ranges_remove.h b/libcxx/include/__algorithm/ranges_remove.h index eb53a5d..dd5c5fb 100644 --- a/libcxx/include/__algorithm/ranges_remove.h +++ b/libcxx/include/__algorithm/ranges_remove.h @@ -35,7 +35,7 @@ struct __fn { template _Sent, class _Type, class _Proj = identity> requires indirect_binary_predicate, const _Type*> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter> operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = {}) const { auto __pred = [&](auto&& __other) { return __value == __other; }; return ranges::__remove_if_impl(std::move(__first), std::move(__last), __pred, __proj); @@ -44,7 +44,7 @@ struct __fn { template requires permutable> && indirect_binary_predicate, _Proj>, const _Type*> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range> operator()(_Range&& __range, const _Type& __value, _Proj __proj = {}) const { auto __pred = [&](auto&& __other) { return __value == __other; }; return ranges::__remove_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); diff --git a/libcxx/include/__algorithm/ranges_remove_if.h b/libcxx/include/__algorithm/ranges_remove_if.h index c2e9052..1f17467 100644 --- a/libcxx/include/__algorithm/ranges_remove_if.h +++ b/libcxx/include/__algorithm/ranges_remove_if.h @@ -56,7 +56,7 @@ struct __fn { template _Sent, class _Proj = identity, indirect_unary_predicate> _Pred> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter> operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const { return ranges::__remove_if_impl(std::move(__first), std::move(__last), __pred, __proj); } @@ -65,7 +65,7 @@ struct __fn { class _Proj = identity, indirect_unary_predicate, _Proj>> _Pred> requires permutable> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range> operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const { return ranges::__remove_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); } diff --git a/libcxx/include/__algorithm/ranges_search.h b/libcxx/include/__algorithm/ranges_search.h index 24bbe28..388d5af 100644 --- a/libcxx/include/__algorithm/ranges_search.h +++ b/libcxx/include/__algorithm/ranges_search.h @@ -75,7 +75,7 @@ struct __fn { class _Proj1 = identity, class _Proj2 = identity> requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter1> operator()(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2, _Pred __pred = {}, @@ -90,7 +90,7 @@ struct __fn { class _Proj1 = identity, class _Proj2 = identity> requires indirectly_comparable, iterator_t<_Range2>, _Pred, _Proj1, _Proj2> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range1> operator()(_Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, diff --git a/libcxx/include/__algorithm/ranges_search_n.h b/libcxx/include/__algorithm/ranges_search_n.h index d2846f6..f44afde 100644 --- a/libcxx/include/__algorithm/ranges_search_n.h +++ b/libcxx/include/__algorithm/ranges_search_n.h @@ -76,7 +76,7 @@ struct __fn { class _Pred = ranges::equal_to, class _Proj = identity> requires indirectly_comparable<_Iter, const _Type*, _Pred, _Proj> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter> operator()(_Iter __first, _Sent __last, iter_difference_t<_Iter> __count, const _Type& __value, @@ -87,7 +87,7 @@ struct __fn { template requires indirectly_comparable, const _Type*, _Pred, _Proj> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range> operator()(_Range&& __range, range_difference_t<_Range> __count, const _Type& __value, diff --git a/libcxx/include/__algorithm/ranges_unique.h b/libcxx/include/__algorithm/ranges_unique.h index 45e5427..be427cc 100644 --- a/libcxx/include/__algorithm/ranges_unique.h +++ b/libcxx/include/__algorithm/ranges_unique.h @@ -45,7 +45,7 @@ namespace __unique { sentinel_for<_Iter> _Sent, class _Proj = identity, indirect_equivalence_relation> _Comp = ranges::equal_to> - _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter> + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter> operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const { auto __ret = std::__unique<_RangeAlgPolicy>( std::move(__first), std::move(__last), std::__make_projected(__comp, __proj)); @@ -57,7 +57,7 @@ namespace __unique { class _Proj = identity, indirect_equivalence_relation, _Proj>> _Comp = ranges::equal_to> requires permutable> - _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range> + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range> operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const { auto __ret = std::__unique<_RangeAlgPolicy>( ranges::begin(__range), ranges::end(__range), std::__make_projected(__comp, __proj)); diff --git a/libcxx/include/__algorithm/ranges_upper_bound.h b/libcxx/include/__algorithm/ranges_upper_bound.h index ec1addd..a134080 100644 --- a/libcxx/include/__algorithm/ranges_upper_bound.h +++ b/libcxx/include/__algorithm/ranges_upper_bound.h @@ -34,7 +34,7 @@ namespace __upper_bound { struct __fn { template _Sent, class _Type, class _Proj = identity, indirect_strict_weak_order> _Comp = ranges::less> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Iter operator()(_Iter __first, _Sent __last, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const { auto __comp_lhs_rhs_swapped = [&](const auto& __lhs, const auto& __rhs) { return !std::invoke(__comp, __rhs, __lhs); @@ -45,7 +45,7 @@ struct __fn { template , _Proj>> _Comp = ranges::less> - _LIBCPP_HIDE_FROM_ABI constexpr + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range> operator()(_Range&& __r, const _Type& __value, _Comp __comp = {}, diff --git a/libcxx/test/libcxx/diagnostics/nodiscard_extensions.pass.cpp b/libcxx/test/libcxx/diagnostics/nodiscard_extensions.compile.pass.cpp similarity index 97% rename from libcxx/test/libcxx/diagnostics/nodiscard_extensions.pass.cpp rename to libcxx/test/libcxx/diagnostics/nodiscard_extensions.compile.pass.cpp index a923301..e0d457b 100644 --- a/libcxx/test/libcxx/diagnostics/nodiscard_extensions.pass.cpp +++ b/libcxx/test/libcxx/diagnostics/nodiscard_extensions.compile.pass.cpp @@ -7,10 +7,7 @@ //===----------------------------------------------------------------------===// // Test that entities declared [[nodiscard]] as at extension by libc++, are -// declared as such when _LIBCPP_DISABLE_NODISCARD_EXT is specified. - -// This test intentionally leaks memory, so it is unsupported under ASAN. -// UNSUPPORTED: asan +// not declared as such when _LIBCPP_DISABLE_NODISCARD_EXT is specified. // All entities to which libc++ applies [[nodiscard]] as an extension should // be tested here and in nodiscard_extensions.verify.cpp. They should also @@ -71,7 +68,7 @@ void test_algorithms() { std::find_if_not(std::begin(arr), std::end(arr), P()); std::find_if(std::begin(arr), std::end(arr), P()); std::find(std::begin(arr), std::end(arr), 1); - std::get_temporary_buffer(1); // intentional memory leak. + std::get_temporary_buffer(1); std::includes(std::begin(arr), std::end(arr), std::begin(arr), std::end(arr)); std::includes(std::begin(arr), std::end(arr), std::begin(arr), std::end(arr), std::greater()); diff --git a/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.compile.pass.cpp b/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.compile.pass.cpp new file mode 100644 index 0000000..1577601 --- /dev/null +++ b/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.compile.pass.cpp @@ -0,0 +1,93 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// Check that ranges algorithms aren't marked [[nodiscard]] when +// _LIBCPP_DISBALE_NODISCARD_EXT is defined + +// UNSUPPORTED: c++03, c++11, c++14 ,c++17 + +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_NODISCARD_EXT + +#include + +void test() { + int range[1]; + int* iter = range; + auto pred = [](auto...) { return true; }; + std::ranges::adjacent_find(range); + std::ranges::adjacent_find(iter, iter); + std::ranges::all_of(range, pred); + std::ranges::all_of(iter, iter, pred); + std::ranges::any_of(range, pred); + std::ranges::any_of(iter, iter, pred); + std::ranges::binary_search(range, 1); + std::ranges::binary_search(iter, iter, 1); + std::ranges::clamp(1, 2, 3); + std::ranges::count_if(range, pred); + std::ranges::count_if(iter, iter, pred); + std::ranges::count(range, 1); + std::ranges::count(iter, iter, 1); + std::ranges::equal_range(range, 1); + std::ranges::equal_range(iter, iter, 1); + std::ranges::equal(range, range); + std::ranges::equal(iter, iter, iter, iter); + std::ranges::find_end(range, range); + std::ranges::find_end(iter, iter, iter, iter); + std::ranges::find_first_of(range, range); + std::ranges::find_first_of(iter, iter, iter, iter); + std::ranges::find_if_not(range, pred); + std::ranges::find_if_not(iter, iter, pred); + std::ranges::find_if(range, pred); + std::ranges::find_if(iter, iter, pred); + std::ranges::find(range, 1); + std::ranges::find(iter, iter, 1); + std::ranges::includes(range, range); + std::ranges::includes(iter, iter, iter, iter); + std::ranges::is_heap_until(range); + std::ranges::is_heap_until(iter, iter); + std::ranges::is_heap(range); + std::ranges::is_heap(iter, iter); + std::ranges::is_partitioned(range, pred); + std::ranges::is_partitioned(iter, iter, pred); + std::ranges::is_permutation(range, range); + std::ranges::is_permutation(iter, iter, iter, iter); + std::ranges::is_sorted_until(range); + std::ranges::is_sorted_until(iter, iter); + std::ranges::is_sorted(range); + std::ranges::is_sorted(iter, iter); + std::ranges::lexicographical_compare(range, range); + std::ranges::lexicographical_compare(iter, iter, iter, iter); + std::ranges::lower_bound(range, 1); + std::ranges::lower_bound(iter, iter, 1); + std::ranges::max_element(range); + std::ranges::max_element(iter, iter); + std::ranges::max(1, 2); + std::ranges::max({1, 2, 3}); + std::ranges::max(range); + std::ranges::minmax_element(range); + std::ranges::minmax_element(iter, iter); + std::ranges::minmax(1, 2); + std::ranges::minmax({1, 2, 3}); + std::ranges::minmax(range); + std::ranges::mismatch(range, range); + std::ranges::mismatch(iter, iter, iter, iter); + std::ranges::none_of(range, pred); + std::ranges::none_of(iter, iter, pred); + std::ranges::remove_if(range, pred); + std::ranges::remove_if(iter, iter, pred); + std::ranges::remove(range, 1); + std::ranges::remove(iter, iter, 1); + std::ranges::search_n(range, 1, 1); + std::ranges::search_n(iter, iter, 1, 1); + std::ranges::search(range, range); + std::ranges::search(iter, iter, iter, iter); + std::ranges::unique(range); + std::ranges::unique(iter, iter); + std::ranges::upper_bound(range, 1); + std::ranges::upper_bound(iter, iter, 1); +} diff --git a/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.verify.cpp b/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.verify.cpp new file mode 100644 index 0000000..77ac5f3 --- /dev/null +++ b/libcxx/test/libcxx/diagnostics/ranges.nodiscard_extensions.verify.cpp @@ -0,0 +1,90 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// Check that ranges algorithms are marked [[nodiscard]] as a conforming extension + +// UNSUPPORTED: c++03, c++11, c++14 ,c++17 + +#include + +void test() { + int range[1]; + int* iter = range; + auto pred = [](auto...) { return true; }; + std::ranges::adjacent_find(range); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::adjacent_find(iter, iter); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::all_of(range, pred); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::all_of(iter, iter, pred); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::any_of(range, pred); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::any_of(iter, iter, pred); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::binary_search(range, 1); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::binary_search(iter, iter, 1); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::clamp(1, 2, 3); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::count_if(range, pred); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::count_if(iter, iter, pred); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::count(range, 1); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::count(iter, iter, 1); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::equal_range(range, 1); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::equal_range(iter, iter, 1); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::equal(range, range); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::equal(iter, iter, iter, iter); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::find_end(range, range); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::find_end(iter, iter, iter, iter); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::find_first_of(range, range); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::find_first_of(iter, iter, iter, iter); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::find_if_not(range, pred); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::find_if_not(iter, iter, pred); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::find_if(range, pred); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::find_if(iter, iter, pred); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::find(range, 1); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::find(iter, iter, 1); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::includes(range, range); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::includes(iter, iter, iter, iter); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::is_heap_until(range); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::is_heap_until(iter, iter); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::is_heap(range); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::is_heap(iter, iter); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::is_partitioned(range, pred); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::is_partitioned(iter, iter, pred); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::is_permutation(range, range); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::is_permutation(iter, iter, iter, iter); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::is_sorted_until(range); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::is_sorted_until(iter, iter); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::is_sorted(range); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::is_sorted(iter, iter); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::lexicographical_compare(range, range); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::lexicographical_compare(iter, iter, iter, iter); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::lower_bound(range, 1); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::lower_bound(iter, iter, 1); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::max_element(range); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::max_element(iter, iter); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::max(1, 2); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::max({1, 2, 3}); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::max(range); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::minmax_element(range); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::minmax_element(iter, iter); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::minmax(1, 2); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::minmax({1, 2, 3}); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::minmax(range); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::mismatch(range, range); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::mismatch(iter, iter, iter, iter); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::none_of(range, pred); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::none_of(iter, iter, pred); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::remove_if(range, pred); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::remove_if(iter, iter, pred); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::remove(range, 1); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::remove(iter, iter, 1); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::search_n(range, 1, 1); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::search_n(iter, iter, 1, 1); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::search(range, range); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::search(iter, iter, iter, iter); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::unique(range); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::unique(iter, iter); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::upper_bound(range, 1); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + std::ranges::upper_bound(iter, iter, 1); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} +} diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.clamp/assert.ranges_clamp.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.clamp/assert.ranges_clamp.pass.cpp index b255b59..1ea5199 100644 --- a/libcxx/test/std/algorithms/alg.sorting/alg.clamp/assert.ranges_clamp.pass.cpp +++ b/libcxx/test/std/algorithms/alg.sorting/alg.clamp/assert.ranges_clamp.pass.cpp @@ -21,14 +21,14 @@ #include "check_assertion.h" int main(int, char**) { - std::ranges::clamp(1, 2, 0, std::ranges::greater{}); + (void)std::ranges::clamp(1, 2, 0, std::ranges::greater{}); TEST_LIBCPP_ASSERT_FAILURE(std::ranges::clamp(1, 2, 0), "Bad bounds passed to std::ranges::clamp"); - std::ranges::clamp(1, 0, 2); - TEST_LIBCPP_ASSERT_FAILURE(std::ranges::clamp(1, 0, 2, std::ranges::greater{}), - "Bad bounds passed to std::ranges::clamp"); + (void)std::ranges::clamp(1, 0, 2); + TEST_LIBCPP_ASSERT_FAILURE( + std::ranges::clamp(1, 0, 2, std::ranges::greater{}), "Bad bounds passed to std::ranges::clamp"); - std::ranges::clamp(1, 1, 1); // Equal bounds should be fine. + (void)std::ranges::clamp(1, 1, 1); // Equal bounds should be fine. return 0; } diff --git a/libcxx/test/std/algorithms/ranges_robust_against_differing_projections.pass.cpp b/libcxx/test/std/algorithms/ranges_robust_against_differing_projections.pass.cpp index 64b3b9d..d940a7a 100644 --- a/libcxx/test/std/algorithms/ranges_robust_against_differing_projections.pass.cpp +++ b/libcxx/test/std/algorithms/ranges_robust_against_differing_projections.pass.cpp @@ -24,8 +24,8 @@ // (in1, in2, ...) template constexpr void test(Func&& func, Input1& in1, Input2& in2, Args&& ...args) { - func(in1.begin(), in1.end(), in2.begin(), in2.end(), std::forward(args)...); - func(in1, in2, std::forward(args)...); + (void)func(in1.begin(), in1.end(), in2.begin(), in2.end(), std::forward(args)...); + (void)func(in1, in2, std::forward(args)...); } constexpr bool test_all() { diff --git a/libcxx/test/std/algorithms/ranges_robust_against_nonbool_predicates.pass.cpp b/libcxx/test/std/algorithms/ranges_robust_against_nonbool_predicates.pass.cpp index 448b8bc..b69df40 100644 --- a/libcxx/test/std/algorithms/ranges_robust_against_nonbool_predicates.pass.cpp +++ b/libcxx/test/std/algorithms/ranges_robust_against_nonbool_predicates.pass.cpp @@ -36,22 +36,22 @@ static_assert(std::convertible_to); // (in, ...) template constexpr void test(Func&& func, Input& in, Args&&... args) { - func(in.begin(), in.end(), std::forward(args)...); - func(in, std::forward(args)...); + (void)func(in.begin(), in.end(), std::forward(args)...); + (void)func(in, std::forward(args)...); } // (in1, in2, ...) template constexpr void test(Func&& func, Input& in1, Input& in2, Args&&... args) { - func(in1.begin(), in1.end(), in2.begin(), in2.end(), std::forward(args)...); - func(in1, in2, std::forward(args)...); + (void)func(in1.begin(), in1.end(), in2.begin(), in2.end(), std::forward(args)...); + (void)func(in1, in2, std::forward(args)...); } // (in, mid, ...) template constexpr void test_mid(Func&& func, Input& in, std::ranges::iterator_t mid, Args&&... args) { - func(in.begin(), mid, in.end(), std::forward(args)...); - func(in, mid, std::forward(args)...); + (void)func(in.begin(), mid, in.end(), std::forward(args)...); + (void)func(in, mid, std::forward(args)...); } constexpr bool test_all() { @@ -83,17 +83,17 @@ constexpr bool test_all() { test(std::ranges::binary_search, in, x, binary_pred); // min - std::ranges::min(1, 2, binary_pred); - std::ranges::min(std::initializer_list{1, 2}, binary_pred); - std::ranges::min(in, binary_pred); + (void)std::ranges::min(1, 2, binary_pred); + (void)std::ranges::min(std::initializer_list{1, 2}, binary_pred); + (void)std::ranges::min(in, binary_pred); // max - std::ranges::max(1, 2, binary_pred); - std::ranges::max(std::initializer_list{1, 2}, binary_pred); - std::ranges::max(in, binary_pred); + (void)std::ranges::max(1, 2, binary_pred); + (void)std::ranges::max(std::initializer_list{1, 2}, binary_pred); + (void)std::ranges::max(in, binary_pred); // minmax - std::ranges::minmax(1, 2, binary_pred); - std::ranges::minmax(std::initializer_list{1, 2}, binary_pred); - std::ranges::minmax(in, binary_pred); + (void)std::ranges::minmax(1, 2, binary_pred); + (void)std::ranges::minmax(std::initializer_list{1, 2}, binary_pred); + (void)std::ranges::minmax(in, binary_pred); test(std::ranges::min_element, in, binary_pred); test(std::ranges::max_element, in, binary_pred); @@ -108,7 +108,7 @@ constexpr bool test_all() { test(std::ranges::includes, in, in2, binary_pred); test(std::ranges::is_heap, in, binary_pred); test(std::ranges::is_heap_until, in, binary_pred); - std::ranges::clamp(2, 1, 3, binary_pred); + (void)std::ranges::clamp(2, 1, 3, binary_pred); test(std::ranges::is_permutation, in, in2, binary_pred); test(std::ranges::copy_if, in, out, unary_pred); test(std::ranges::remove_copy_if, in, out, unary_pred); diff --git a/libcxx/test/std/algorithms/ranges_robust_against_omitting_invoke.pass.cpp b/libcxx/test/std/algorithms/ranges_robust_against_omitting_invoke.pass.cpp index 9831020..35b9f92 100644 --- a/libcxx/test/std/algorithms/ranges_robust_against_omitting_invoke.pass.cpp +++ b/libcxx/test/std/algorithms/ranges_robust_against_omitting_invoke.pass.cpp @@ -37,22 +37,22 @@ struct Bar { // (in, ...) template constexpr void test(Func&& func, Input& in, Args&&... args) { - func(in.begin(), in.end(), std::forward(args)...); - func(in, std::forward(args)...); + (void)func(in.begin(), in.end(), std::forward(args)...); + (void)func(in, std::forward(args)...); } // (in1, in2, ...) template constexpr void test(Func&& func, Input& in1, Input& in2, Args&&... args) { - func(in1.begin(), in1.end(), in2.begin(), in2.end(), std::forward(args)...); - func(in1, in2, std::forward(args)...); + (void)func(in1.begin(), in1.end(), in2.begin(), in2.end(), std::forward(args)...); + (void)func(in1, in2, std::forward(args)...); } // (in, mid, ...) template constexpr void test_mid(Func&& func, Input& in, std::ranges::iterator_t mid, Args&&... args) { - func(in.begin(), mid, in.end(), std::forward(args)...); - func(in, mid, std::forward(args)...); + (void)func(in.begin(), mid, in.end(), std::forward(args)...); + (void)func(in, mid, std::forward(args)...); } constexpr bool test_all() { @@ -89,17 +89,17 @@ constexpr bool test_all() { test(std::ranges::binary_search, in, x, &Foo::binary_pred, &Bar::val); // min - std::ranges::min(a, b, &Foo::binary_pred, &Bar::val); - std::ranges::min(std::initializer_list{a, b}, &Foo::binary_pred, &Bar::val); - std::ranges::min(in, &Foo::binary_pred, &Bar::val); + (void)std::ranges::min(a, b, &Foo::binary_pred, &Bar::val); + (void)std::ranges::min(std::initializer_list{a, b}, &Foo::binary_pred, &Bar::val); + (void)std::ranges::min(in, &Foo::binary_pred, &Bar::val); // max - std::ranges::max(a, b, &Foo::binary_pred, &Bar::val); - std::ranges::max(std::initializer_list{a, b}, &Foo::binary_pred, &Bar::val); - std::ranges::max(in, &Foo::binary_pred, &Bar::val); + (void)std::ranges::max(a, b, &Foo::binary_pred, &Bar::val); + (void)std::ranges::max(std::initializer_list{a, b}, &Foo::binary_pred, &Bar::val); + (void)std::ranges::max(in, &Foo::binary_pred, &Bar::val); // minmax - std::ranges::minmax(a, b, &Foo::binary_pred, &Bar::val); - std::ranges::minmax(std::initializer_list{a, b}, &Foo::binary_pred, &Bar::val); - std::ranges::minmax(in, &Foo::binary_pred, &Bar::val); + (void)std::ranges::minmax(a, b, &Foo::binary_pred, &Bar::val); + (void)std::ranges::minmax(std::initializer_list{a, b}, &Foo::binary_pred, &Bar::val); + (void)std::ranges::minmax(in, &Foo::binary_pred, &Bar::val); test(std::ranges::min_element, in, &Foo::binary_pred, &Bar::val); test(std::ranges::max_element, in, &Foo::binary_pred, &Bar::val); @@ -115,7 +115,7 @@ constexpr bool test_all() { test(std::ranges::includes, in, in2, &Foo::binary_pred, &Bar::val, &Bar::val); test(std::ranges::is_heap, in, &Foo::binary_pred, &Bar::val); test(std::ranges::is_heap_until, in, &Foo::binary_pred, &Bar::val); - std::ranges::clamp(b, a, c, &Foo::binary_pred, &Bar::val); + (void)std::ranges::clamp(b, a, c, &Foo::binary_pred, &Bar::val); test(std::ranges::is_permutation, in, in2, &Foo::binary_pred, &Bar::val, &Bar::val); test(std::ranges::for_each, in, &Foo::unary_pred, &Bar::val); std::ranges::for_each_n(in.begin(), count, &Foo::unary_pred, &Bar::val); diff --git a/libcxx/test/std/algorithms/ranges_robust_against_proxy_iterators.pass.cpp b/libcxx/test/std/algorithms/ranges_robust_against_proxy_iterators.pass.cpp index 3458336..d383e18 100644 --- a/libcxx/test/std/algorithms/ranges_robust_against_proxy_iterators.pass.cpp +++ b/libcxx/test/std/algorithms/ranges_robust_against_proxy_iterators.pass.cpp @@ -29,22 +29,22 @@ // (in, ...) template constexpr void test(Func&& func, Input& in, Args&& ...args) { - func(in.begin(), in.end(), std::forward(args)...); - func(in, std::forward(args)...); + (void)func(in.begin(), in.end(), std::forward(args)...); + (void)func(in, std::forward(args)...); } // (in1, in2, ...) template constexpr void test(Func&& func, Range1& r1, Range2& r2, Args&& ...args) { - func(r1.begin(), r1.end(), r2.begin(), r2.end(), std::forward(args)...); - func(r1, r2, std::forward(args)...); + (void)func(r1.begin(), r1.end(), r2.begin(), r2.end(), std::forward(args)...); + (void)func(r1, r2, std::forward(args)...); } // (in, mid, ...) template constexpr void test_mid(Func&& func, Input& in, std::ranges::iterator_t mid, Args&& ...args) { - func(in.begin(), mid, in.end(), std::forward(args)...); - func(in, mid, std::forward(args)...); + (void)func(in.begin(), mid, in.end(), std::forward(args)...); + (void)func(in, mid, std::forward(args)...); } std::mt19937 rand_gen() { return std::mt19937(); }