Hi,
aside from the fact that the new coroutines are - apparently intentionally - only unidirectional now (currently not much of an issue for me), I noticed that it is apparently no longer possible to yield values by reference as shown in the following example:
#include <fstream>
#include <string>
#include <iostream>
#include
using type = std::string;
auto lines_from_file(char const * fname) -> boost::coroutines::coroutine<type>::pull_type
{
using namespace boost::coroutines;
return coroutine<type>::pull_type{
[fname](coroutine<type>::push_type& yield)
{
std::string line;
std::ifstream stream(fname);
while(stream)
std::getline(stream, line), yield(line);
},
attributes(fpu_not_preserved)
};
}
int main(int, char**)
{
auto lines = lines_from_file("test.txt");
unsigned count = 0;
for(auto& line : lines)
std::cout << std::setw(4) << ++count << ": " << line << "\n";
}
If one changes type to std::string const & the example no longer compiles. If I use the old BOOST_COROUTINES_V1 API boost::coroutines::coroutine works just fine. Is this limitation also intentional (why?) or is this an unintentional regression?
Regards
Johannes S. Mueller-Roemer
--
Johannes S. Mueller-Roemer, MSc
Wiss. Mitarbeiter - Interactive Engineering Technologies (IET)
Fraunhofer-Institut für Graphische Datenverarbeitung IGD
Fraunhoferstr. 5 | 64283 Darmstadt | Germany
Tel +49 6151 155-606 | Fax +49 6151 155-139
johannes.mueller-roemer@igd.fraunhofer.de | www.igd.fraunhofer.de