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
This commit is contained in:
Hanos-Puskai Peter 2021-08-10 17:58:37 +03:00
parent 90d3194928
commit 37f08bb818

View File

@ -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