| 1 |
#include "floats.ih" |
| 2 |
|
| 3 |
// this function merely uses the coroutine's next value. |
| 4 |
|
| 5 |
//write |
| 6 |
void Floats::write() const |
| 7 |
{ |
| 8 |
ofstream out{ d_filename }; |
| 9 |
|
| 10 |
Writer writer = coWrite(); // coWrite: the coroutine, |
| 11 |
// writer: the coroutine's handler |
| 12 |
cout << "Enter values (one per prompt), enter 'q' to quit\n"; |
| 13 |
|
| 14 |
while (true) |
| 15 |
{ |
| 16 |
cout << "? "; |
| 17 |
auto opt = writer.next(); // retrieve the next value |
| 18 |
if (not opt) // stop if no more values |
| 19 |
break; |
| 20 |
out.write(&opt.value()[0], sizeof(float)); |
| 21 |
} |
| 22 |
} |
| 23 |
//= |