| 59 | //[tutorial_karma_complex_number |
| 60 | template <typename OutputIterator> |
| 61 | bool generate_complex(OutputIterator sink, std::complex<double> const& c) |
| 62 | { |
| 63 | using boost::spirit::karma::eps; |
| 64 | using boost::spirit::karma::double_; |
| 65 | using boost::spirit::karma::_1; |
| 66 | using boost::spirit::karma::generate; |
| 67 | |
| 68 | return generate(sink, |
| 69 | // Begin grammar |
| 70 | ( |
| 71 | eps(c.imag() != 0) << |
| 72 | '(' << double_[_1 = c.real()] << ", " << double_[_1 = c.imag()] << ')' |
| 73 | | double_[_1 = c.real()] |
| 74 | ) |
| 75 | // End grammar |
| 76 | ); |
| 77 | } |
| 78 | //] |
| 79 | } |
| 80 | |