List:MySQL++« Previous MessageNext Message »
From:Rick Gutleber Date:November 19 2008 8:52pm
Subject:Unexpected results with stock (was Re: Here goes nothing.)
View as plain text  
Warren Young wrote:
>>
>> I didn't do this because it won't take that line without casts for at 
>> least some of those arguments
>         stock_vector.push_back(stock(strings[0], strings[1]...);
>
> Probably just stock.sdate.  It's easy to fix: just wrap it in Date().
>
>> I would have expected implicit casts to kick in since the arguments 
>> are of type mysqlpp::String.  Am I missing something?
>
> We had implicit conversion from stringish types to Date, DateTime and 
> Time in v2, but it conflicted with the SSQLS extensions in v3.

Surprisingly, that wasn't the problem.  More surprisingly, the problem 
was with the _first_ arg, the one I figured you'd mostly likely get for 
free!  Through trial and error, I narrowed it down to the following:

stock_vector.push_back(stock(mysqlpp::sql_char(strings[0]),strings[1],strings[2],strings[3],strings[4],strings[5]));



which of course is a synonym for:

stock_vector.push_back(stock(string(strings[0]),strings[1],strings[2],strings[3],strings[4],strings[5]));


 
Of course, this all goes back to std::string not having an implicit cast 
from const char *, which I'm sure is for a good (and probably obscure) 
reason, but is nonetheless really annoying.  Of course, that's 
especially the case after some 10 years using my own string class which 
was much way more fleshed out than std::string.

Even more odd, the last parameter, which is also a string, _doesn't_ 
require a cast.   It is however a Nullable (const 
mysqlpp::Null<std::string, mysqlpp::NullIsNull>&) so I guess somehow the 
compiler was able to wheedle out a proper conversion.

It works, so there's no problem at this point... just some very 
unexpected things along the way.

Rick


Thread
Re: Here goes nothing.Warren Young17 Nov
  • Re: Here goes nothing.Rick Gutleber19 Nov
    • Re: Here goes nothing.Warren Young19 Nov
      • Re: Here goes nothing.Rick Gutleber19 Nov
        • Re: Here goes nothing.Jonathan Wakely20 Nov
      • Unexpected results with stock (was Re: Here goes nothing.)Rick Gutleber19 Nov
Re: Here goes nothing.Warren Young17 Nov