|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r82869 - in trunk: boost/coroutine/detail libs/coroutine/doc libs/coroutine/test
From: oliver.kowalke_at_[hidden]
Date: 2013-02-14 07:29:52
Author: olli
Date: 2013-02-14 07:29:51 EST (Thu, 14 Feb 2013)
New Revision: 82869
URL: http://svn.boost.org/trac/boost/changeset/82869
Log:
coroutine: fix for bug #8024 - create const_iterator from coroutine
Text files modified:
trunk/boost/coroutine/detail/coroutine_op.hpp | 14 ++++----
trunk/libs/coroutine/doc/Jamfile.v2 | 6 ---
trunk/libs/coroutine/test/test_coroutine.cpp | 63 +++++++++++++++++++++++++++++++++------
3 files changed, 59 insertions(+), 24 deletions(-)
Modified: trunk/boost/coroutine/detail/coroutine_op.hpp
==============================================================================
--- trunk/boost/coroutine/detail/coroutine_op.hpp (original)
+++ trunk/boost/coroutine/detail/coroutine_op.hpp 2013-02-14 07:29:51 EST (Thu, 14 Feb 2013)
@@ -123,11 +123,11 @@
{ return const_cast< optional< Result > & >( val_).get_ptr(); }
};
- class const_iterator : public std::iterator< std::input_iterator_tag, typename remove_reference< const Result >::type >
+ class const_iterator : public std::iterator< std::input_iterator_tag, const typename remove_reference< Result >::type >
{
private:
- D * dp_;
- optional< const Result > val_;
+ D * dp_;
+ optional< Result > val_;
void fetch_()
{
@@ -152,15 +152,15 @@
}
public:
- typedef typename iterator::pointer pointer_t;
- typedef typename iterator::reference reference_t;
+ typedef typename const_iterator::pointer pointer_t;
+ typedef typename const_iterator::reference reference_t;
const_iterator() :
dp_( 0), val_()
{}
- explicit const_iterator( D * dp) :
- dp_( dp), val_()
+ explicit const_iterator( D const* dp) :
+ dp_( const_cast< D * >( dp) ), val_()
{ fetch_(); }
const_iterator( const_iterator const& other) :
Modified: trunk/libs/coroutine/doc/Jamfile.v2
==============================================================================
--- trunk/libs/coroutine/doc/Jamfile.v2 (original)
+++ trunk/libs/coroutine/doc/Jamfile.v2 2013-02-14 07:29:51 EST (Thu, 14 Feb 2013)
@@ -9,9 +9,6 @@
import quickbook ;
import modules ;
-path-constant images_location : html ;
-path-constant here : . ;
-
boostbook coro
:
coro.qbk
@@ -29,7 +26,4 @@
<xsl:param>toc.max.depth=3
# How far down we go with TOC's
<xsl:param>generate.section.toc.level=10
- <format>pdf:<xsl:param>img.src.path=$(images_location)/
;
-
-
Modified: trunk/libs/coroutine/test/test_coroutine.cpp
==============================================================================
--- trunk/libs/coroutine/test/test_coroutine.cpp (original)
+++ trunk/libs/coroutine/test/test_coroutine.cpp 2013-02-14 07:29:51 EST (Thu, 14 Feb 2013)
@@ -42,6 +42,7 @@
typedef coro::coroutine< int*(int*) > coro_ptr;
typedef coro::coroutine< int const&(int const&) > coro_ref;
typedef coro::coroutine< boost::tuple<int&,int&>(int&,int&) > coro_tuple;
+typedef coro::coroutine< const int *() > coro_const_int_ptr_void;
struct X : private boost::noncopyable
{
@@ -200,6 +201,12 @@
}
}
+void f19( coro_const_int_ptr_void::caller_type & self, std::vector< const int * > & vec)
+{
+ BOOST_FOREACH( const int * ptr, vec)
+ { self( ptr); }
+}
+
void test_move()
{
{
@@ -410,16 +417,51 @@
void test_output_iterator()
{
- std::vector< int > vec;
- coro_int_void coro( f16);
- BOOST_FOREACH( int i, coro)
- { vec.push_back( i); }
- BOOST_CHECK_EQUAL( ( std::size_t)5, vec.size() );
- BOOST_CHECK_EQUAL( ( int)1, vec[0] );
- BOOST_CHECK_EQUAL( ( int)2, vec[1] );
- BOOST_CHECK_EQUAL( ( int)3, vec[2] );
- BOOST_CHECK_EQUAL( ( int)4, vec[3] );
- BOOST_CHECK_EQUAL( ( int)5, vec[4] );
+ {
+ std::vector< int > vec;
+ coro_int_void coro( f16);
+ BOOST_FOREACH( int i, coro)
+ { vec.push_back( i); }
+ BOOST_CHECK_EQUAL( ( std::size_t)5, vec.size() );
+ BOOST_CHECK_EQUAL( ( int)1, vec[0] );
+ BOOST_CHECK_EQUAL( ( int)2, vec[1] );
+ BOOST_CHECK_EQUAL( ( int)3, vec[2] );
+ BOOST_CHECK_EQUAL( ( int)4, vec[3] );
+ BOOST_CHECK_EQUAL( ( int)5, vec[4] );
+ }
+ {
+ std::vector< int > vec;
+ coro_int_void coro( f16);
+ coro_int_void::iterator e = boost::end( coro);
+ for (
+ coro_int_void::iterator i = boost::begin( coro);
+ i != e; ++i)
+ { vec.push_back( * i); }
+ BOOST_CHECK_EQUAL( ( std::size_t)5, vec.size() );
+ BOOST_CHECK_EQUAL( ( int)1, vec[0] );
+ BOOST_CHECK_EQUAL( ( int)2, vec[1] );
+ BOOST_CHECK_EQUAL( ( int)3, vec[2] );
+ BOOST_CHECK_EQUAL( ( int)4, vec[3] );
+ BOOST_CHECK_EQUAL( ( int)5, vec[4] );
+ }
+ {
+ int i1 = 1, i2 = 2, i3 = 3;
+ std::vector< const int* > vec_in;
+ vec_in.push_back( & i1);
+ vec_in.push_back( & i2);
+ vec_in.push_back( & i3);
+ std::vector< const int* > vec_out;
+ coro_const_int_ptr_void coro( boost::bind( f19, _1, boost::ref( vec_in) ) );
+ coro_const_int_ptr_void::const_iterator e = boost::const_end( coro);
+ for (
+ coro_const_int_ptr_void::const_iterator i = boost::const_begin( coro);
+ i != e; ++i)
+ { vec_out.push_back( * i); }
+ BOOST_CHECK_EQUAL( ( std::size_t)3, vec_out.size() );
+ BOOST_CHECK_EQUAL( & i1, vec_out[0] );
+ BOOST_CHECK_EQUAL( & i2, vec_out[1] );
+ BOOST_CHECK_EQUAL( & i3, vec_out[2] );
+ }
}
void test_input_iterator()
@@ -465,7 +507,6 @@
BOOST_CHECK( ! coro);
}
-
boost::unit_test::test_suite * init_unit_test_suite( int, char* [])
{
boost::unit_test::test_suite * test =
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk