Subject: Re: [Boost-bugs] [Boost C++ Libraries] #8024: Unable to create const_iterator for coroutine
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-02-18 05:55:31
#8024: Unable to create const_iterator for coroutine
-------------------------------+--------------------------------------------
Reporter: nathanridge | Owner: olli
Type: Bugs | Status: reopened
Milestone: To Be Determined | Component: coroutine
Version: Boost 1.53.0 | Severity: Problem
Resolution: | Keywords:
-------------------------------+--------------------------------------------
Changes (by nathanridge):
* status: closed => reopened
* resolution: fixed =>
Comment:
What I'm really trying to get to work is code like the following:
{{{
#include <iostream>
#include <boost/coroutine/coroutine.hpp>
typedef boost::coroutines::coroutine<int()> coro_t;
void foo(coro_t::caller_type& caller)
{
caller(0);
caller(1);
caller(2);
}
coro_t f()
{
return coro_t(&foo);
}
template <typename Range>
void print_range(const Range& range)
{
for (auto element : range)
std::cout << element;
}
int main()
{
print_range(f());
}
}}}
The C++11 range-based for loop requires either that the range type have a
member function named 'begin', or that there exist a non-member function
named 'begin' that is found by argument-dependent lookup (i.e. in the same
namespace as the range type). In either case, the 'begin' function should
have a const version that returns a const iterator.
What that translates to for coroutines is that either coroutine needs to
have a member function with the signature "begin() const" or there needs
to be a non-member function named "begin" in "boost::coroutines" that
takes a "const coroutine&" parameter. (And of course the same for 'end').
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/8024#comment:2> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:12 UTC