Remove addtional parameters in function std::next() and std::prev()
Creating a function pointer with proper parameters pointing to std::next() or std::prev() should work.
This change moves the invented paramater for enable_if over to the return type to resolve this QoI issue.
Patch by Jason Liu.
Differential Revision: https://reviews.llvm.org/D34649
llvm-svn: 308932
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: 3e2ef40812204da7098c917c37ad4c8306fb65c7
diff --git a/include/iterator b/include/iterator
index d163ab1..9e1da93 100644
--- a/include/iterator
+++ b/include/iterator
@@ -604,21 +604,27 @@
template <class _InputIter>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-_InputIter
+typename enable_if
+<
+ __is_input_iterator<_InputIter>::value,
+ _InputIter
+>::type
next(_InputIter __x,
- typename iterator_traits<_InputIter>::difference_type __n = 1,
- typename enable_if<__is_input_iterator<_InputIter>::value>::type* = 0)
+ typename iterator_traits<_InputIter>::difference_type __n = 1)
{
_VSTD::advance(__x, __n);
return __x;
}
-template <class _BidiretionalIter>
+template <class _BidirectionalIter>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
-_BidiretionalIter
-prev(_BidiretionalIter __x,
- typename iterator_traits<_BidiretionalIter>::difference_type __n = 1,
- typename enable_if<__is_bidirectional_iterator<_BidiretionalIter>::value>::type* = 0)
+typename enable_if
+<
+ __is_bidirectional_iterator<_BidirectionalIter>::value,
+ _BidirectionalIter
+>::type
+prev(_BidirectionalIter __x,
+ typename iterator_traits<_BidirectionalIter>::difference_type __n = 1)
{
_VSTD::advance(__x, -__n);
return __x;