fix example for multiple definitions

This commit is contained in:
Oliver Kowalke
2014-08-23 13:39:24 +02:00
parent 06145727ee
commit c15ffa7146
3 changed files with 31 additions and 13 deletions

View File

@@ -0,0 +1,13 @@
#ifndef X_H
#define X_H
struct X
{
int i;
X( int i_) :
i( i_)
{}
};
#endif // X_H

View File

@@ -4,14 +4,7 @@
#include <boost/bind.hpp>
#include <boost/coroutine/all.hpp>
struct X
{
int i;
X( int i_) :
i( i_)
{}
};
#include "X.h"
typedef boost::coroutines::asymmetric_coroutine< X& >::pull_type pull_coro_t;
typedef boost::coroutines::asymmetric_coroutine< X& >::push_type push_coro_t;

View File

@@ -1,18 +1,26 @@
#include <boost/bind.hpp>
#include <boost/coroutine/all.hpp>
typedef boost::coroutines::asymmetric_coroutine< void >::pull_type pull_coro_t;
typedef boost::coroutines::asymmetric_coroutine< void >::push_type push_coro_t;
#include "X.h"
typedef boost::coroutines::asymmetric_coroutine< X& >::pull_type pull_coro_t;
typedef boost::coroutines::asymmetric_coroutine< X& >::push_type push_coro_t;
void foo1( push_coro_t & sink)
{
for ( int i = 0; i < 10; ++i)
sink();
{
X x( i);
sink( x);
}
}
void foo2( pull_coro_t & source)
{
while ( source)
while ( source) {
X & x = source.get();
source();
}
}
void bar()
@@ -20,13 +28,17 @@ void bar()
{
pull_coro_t source( foo1);
while ( source) {
X & x = source.get();
source();
}
}
{
push_coro_t sink( foo2);
for ( int i = 0; i < 10; ++i)
sink();
{
X x( i);
sink( x);
}
}
}