5 Feb 22:45
Rule and C++11 auto type on VS2010
Claude <clros <at> tiscali.it>
2012-02-05 21:45:54 GMT
2012-02-05 21:45:54 GMT
Hi!
I used this code for parsing a date in format yyyy-mm-dd:
uint32_t day=0,month=0;
uint32_t year;
std::string myStr("1974-5-10");
std::string::const_iterator begin = myStr.begin(), end = myStr.end();
auto rDate = qi::uint_>>'-'>>qi::uint_>>'-'>>qi::uint_;
if (qi::phrase_parse(begin, end, rDate, qi::space,year,month,day) )
{
cout<<"Parse Ok!"<<endl;
cout<<"Year: "<<year<<" Month:
"<<month<<" Day: "<<day<<endl;
}
This code work well, but if I use it in most complex program, it don’t work
<smiley image="smiley_what.gif"/>
I discovered that the problem is the rDate variable. If it is a C++11 /auto/
variable, in my complex program, on the Visual C++2010, phrase_parse() don’t
parse correctly. (this problem are not present on GCC 4.6.1 on Ubuntu!)
For this reason I changed the rValue type:
qi::rule<std::string::const_iterator> rDate =
qi::uint_>>'-'>>qi::uint_>>'-'>>qi::uint_;
(Continue reading)
RSS Feed