Claude | 5 Feb 22:45
Picon
Favicon

Rule and C++11 auto type on VS2010

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&lt;&lt;&quot;Year: &quot;&lt;&lt;year&lt;&lt;&quot; Month:
&quot;&lt;&lt;month&lt;&lt;&quot; Day: &quot;&lt;&lt;day&lt;&lt;endl;
	}

This code work well, but if I use it in most complex program, it don’t work
&lt;smiley image=&quot;smiley_what.gif&quot;/>

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)

Michael Caisse | 5 Feb 23:14

Re: Rule and C++11 auto type on VS2010

Hi Claude -

On 2/5/2012 1:45 PM, Claude wrote:
> Hi!
> I used this code for parsing a date in format yyyy-mm-dd:
>

<snip code>

>
>      auto rDate = qi::uint_>>'-'>>qi::uint_>>'-'>>qi::uint_;
>

>
> 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_;
> 	
> Now phrase_parse() work, but I don’t obtain the correct value of year,month
> an day.
>
> I think the problem is the type of rdate.
> How can I fix?
>
> Why in Visual C++ auto type don't work correctly?
(Continue reading)


Gmane