From 37f08bb8188e3af81869ee5c12ba5bee30d2101a Mon Sep 17 00:00:00 2001 From: Hanos-Puskai Peter Date: Tue, 10 Aug 2021 17:58:37 +0300 Subject: [PATCH] Fix ambiguity of std::begin/end - this patch should restore the range-based for functionality for pull-type coroutines - it also keeps the behaviour when using std::begin / std::end if some standard container's header is included - it also eliminates the possible undefined behaviour / ill-formedness caused by the custom overload of std::begin / std::end --- .../coroutine2/detail/pull_coroutine.hpp | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/include/boost/coroutine2/detail/pull_coroutine.hpp b/include/boost/coroutine2/detail/pull_coroutine.hpp index 96d10d6..767a388 100644 --- a/include/boost/coroutine2/detail/pull_coroutine.hpp +++ b/include/boost/coroutine2/detail/pull_coroutine.hpp @@ -130,6 +130,9 @@ public: }; friend class iterator; + + iterator begin() { return iterator (this); } + iterator end() { return iterator(); } }; template< typename T > @@ -238,6 +241,9 @@ public: }; friend class iterator; + + iterator begin() { return iterator (this); } + iterator end() { return iterator(); } }; template<> @@ -278,6 +284,8 @@ public: explicit operator bool() const noexcept; bool operator!() const noexcept; + + }; template< typename T > @@ -294,22 +302,6 @@ end( pull_coroutine< T > &) { }}} -namespace std { - -template< typename T > -typename boost::coroutines2::detail::pull_coroutine< T >::iterator -begin( boost::coroutines2::detail::pull_coroutine< T > & c) { - return boost::coroutines2::detail::begin( c); -} - -template< typename T > -typename boost::coroutines2::detail::pull_coroutine< T >::iterator -end( boost::coroutines2::detail::pull_coroutine< T > & c) { - return boost::coroutines2::detail::end( c); -} - -} - #ifdef BOOST_HAS_ABI_HEADERS # include BOOST_ABI_SUFFIX #endif