[libcxx-commits] [libcxx] [libc++] Disallow std::prev(non_cpp17_bidi_iterator) (PR #112102)

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Tue Oct 15 08:27:08 PDT 2024


================
@@ -35,6 +39,13 @@ prev(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n =
   return __x;
 }
 
+template <class _BidirectionalIterator,
+          __enable_if_t<__has_bidirectional_iterator_category<_BidirectionalIterator>::value, int> = 0>
+[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 _BidirectionalIterator
+prev(_BidirectionalIterator __it) {
+  return std::prev(std::move(__it), 1);
+}
----------------
frederick-vs-ja wrote:

[LWG4100](https://cplusplus.github.io/LWG/issue4100) might also be related. It's unclear whether additional signatures of standard free functions are allowed. And it's squirrelly that two such overloads have different conditions on well-formedness.

https://github.com/llvm/llvm-project/pull/112102


More information about the libcxx-commits mailing list