provide std::begin/std::end overloads for pull_coroutine

This commit is contained in:
Oliver Kowalke 2020-07-02 08:59:04 +02:00
parent 4569842e94
commit 1a97defc28
3 changed files with 30 additions and 17 deletions

View File

@ -103,8 +103,8 @@ int main()
traverse(left_d,out);
});
std::cout << "left tree from d:\n";
std::copy(begin(left_d_reader),
end(left_d_reader),
std::copy(std::begin(left_d_reader),
std::end(left_d_reader),
std::ostream_iterator<std::string>(std::cout, " "));
std::cout << std::endl;
@ -113,8 +113,8 @@ int main()
traverse(right_b,out);
});
std::cout << "right tree from b:\n";
std::copy(begin(right_b_reader),
end(right_b_reader),
std::copy(std::begin(right_b_reader),
std::end(right_b_reader),
std::ostream_iterator<std::string>(std::cout, " "));
std::cout << std::endl;
@ -123,8 +123,8 @@ int main()
traverse(right_x,out);
});
std::cout << "right tree from x:\n";
std::copy(begin(right_x_reader),
end(right_x_reader),
std::copy(std::begin(right_x_reader),
std::end(right_x_reader),
std::ostream_iterator<std::string>(std::cout, " "));
std::cout << std::endl;
}
@ -146,9 +146,9 @@ int main()
std::cout << "left tree from d == right tree from b? "
<< std::boolalpha
<< std::equal(begin(left_d_reader),
end(left_d_reader),
begin(right_b_reader))
<< std::equal(std::begin(left_d_reader),
std::end(left_d_reader),
std::begin(right_b_reader))
<< std::endl;
}
}
@ -169,9 +169,9 @@ int main()
std::cout << "left tree from d == right tree from x? "
<< std::boolalpha
<< std::equal(begin(left_d_reader),
end(left_d_reader),
begin(right_x_reader))
<< std::equal(std::begin(left_d_reader),
std::end(left_d_reader),
std::begin(right_x_reader))
<< std::endl;
}
}

View File

@ -294,6 +294,22 @@ 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

View File

@ -518,14 +518,11 @@ void test_exceptions()
void test_input_iterator()
{
{
using std::begin;
using std::end;
std::vector< int > vec;
coro::coroutine< int >::pull_type coro( f16);
coro::coroutine< int >::pull_type::iterator e = end( coro);
coro::coroutine< int >::pull_type::iterator e = std::end( coro);
for (
coro::coroutine< int >::pull_type::iterator i = begin( coro);
coro::coroutine< int >::pull_type::iterator i = std::begin( coro);
i != e; ++i)
{ vec.push_back( * i); }
BOOST_CHECK_EQUAL( ( std::size_t)5, vec.size() );