Re: newbie here ask about qi::_val and semantic action
Henri Menke <[email protected]> Mon, 9 Jul 2018 14:06:03 +1200
| Newsgroups | gmane.comp.parsers.spirit.general |
|---|---|
| Message-ID | <[email protected]> |
Elaborate. The following works.
#include <iostream>
#include <string>
#include <boost/spirit/include/phoenix.hpp>
#include <boost/spirit/include/qi.hpp>
int main() {
std::string s = "1234.56789";
double d;
std::string::iterator first = s.begin();
std::string::iterator last = s.end();
namespace qi = boost::spirit::qi;
bool r = qi::phrase_parse(first, last, qi::double_ [qi::_val =
qi::_1], qi::space, d);
if (!r || first != last) {
std::cerr << "Error while parsing. Rest: " <<
std::string(first, last) << "\n";
}
std::cout << "Success! " << d << "\n";
}
On 09/07/18 03:40, Yi Leong wrote:
> Hi,
> I set qi::_val in semantic action function , but it does not work.
> Is the placeholder _val only usable in lambda expression?
>
>
>
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>
>
>
> _______________________________________________
> Spirit-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/spirit-general
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot