MCPcopy Create free account
hub / github.com/boostorg/spirit / parse_complex

Function parse_complex

example/karma/complex_number_adapt.cpp:50–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48 ///////////////////////////////////////////////////////////////////////////
49 template <typename Iterator>
50 bool parse_complex(Iterator first, Iterator last, std::complex<double>& c)
51 {
52 using boost::spirit::qi::double_;
53 using boost::spirit::qi::_1;
54 using boost::spirit::qi::phrase_parse;
55 using boost::spirit::ascii::space;
56 using boost::phoenix::ref;
57
58 double rN = 0.0;
59 double iN = 0.0;
60 bool r = phrase_parse(first, last,
61 (
62 '(' >> double_[ref(rN) = _1]
63 >> -(',' >> double_[ref(iN) = _1]) >> ')'
64 | double_[ref(rN) = _1]
65 ),
66 space);
67
68 if (!r || first != last) // fail if we did not get a full match
69 return false;
70 c = std::complex<double>(rN, iN);
71 return r;
72 }
73
74 ///////////////////////////////////////////////////////////////////////////
75 // Our complex number generator

Callers 1

mainFunction · 0.70

Calls 1

phrase_parseFunction · 0.50

Tested by

no test coverage detected