[Boost-bugs] [Boost C++ Libraries] #7988: [Coroutine] Support for C++11 range-for is missing

Subject: [Boost-bugs] [Boost C++ Libraries] #7988: [Coroutine] Support for C++11 range-for is missing
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-02-06 03:27:16


#7988: [Coroutine] Support for C++11 range-for is missing
---------------------+------------------------------------------------------
 Reporter: ld | Type: Bugs
   Status: new | Milestone: To Be Determined
Component: None | Version: Boost 1.53.0
 Severity: Problem | Keywords:
---------------------+------------------------------------------------------
 Using a snapshot of the upcoming GCC 4.8 release and Boost 1.53, the
 following does not compile:

 {{{#!cpp
 #include <boost/coroutine/all.hpp>

 int main()
 {
     using coro = boost::coroutines::coroutine<int()>;
     for(int i: coro { [](coro::caller_type& yield) { yield(42); } }) {
         // unused
         static_cast<void>(i);
     }
 }
 }}}

 As far as I can tell, this is because while Boost.Coroutine does provide
 functionality for e.g. boost::begin(c) and boost::end(c), it does not
 provide for the similar, ADL-enabled uses like begin(c) and end(c), where
 begin and end are in scope.

 As it so happens, boost::begin and boost::end do ADL on behalf of the
 users -- their Standard counterparts do not, and a range-for statement is
 specified to make use of unqualified calls to begin and end.

 To substantiate my hypothesis, adding begin and end function templates in
 e.g. namespace boost::coroutines does appear to make the previous snippet
 compile, and more involved examples behave as expected.

 {{{#!cpp
 // Try adding this:
 namespace boost { namespace coroutines {

 template<typename Sig> auto begin(coroutine<Sig>& c)
 -> decltype(boost::begin(c))
 { return boost::begin(c); }

 template<typename Sig> auto end(coroutine<Sig>& c)
 -> decltype(boost::end(c))
 { return boost::end(c); }

 } }
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/7988>
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:11 UTC