From: Warren Young Date: August 16 2012 11:33am Subject: Re: Problem with types in sql_types.h List-Archive: http://lists.mysql.com/plusplus/9530 Message-Id: <502CDA7E.9000705@etr-usa.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 8/16/2012 4:03 AM, Joseph Hesse wrote: > x = res[i]["Cost"]; // THIS LINE WON'T COMPILE In future, please include compiler error messages with reporting such problems. We don't all use the same toolchains or platforms. Even if we did happen to in this case, that doesn't mean your test case is enough to match your symptom in all cases. I assume you are getting an ambiguous operator error? If so, the simple fix is: mysqlpp::sql_double_null x = res[i]["Cost"]; That is, don't separate the declaration and assignment. Why does this work? Because it causes a call to a Null constructor, instead of Null::operator=(). I'm not sure why this doesn't work just as well, though: mysqlpp::sql_double_null x(res[i]["Cost"]); That should also call a ctor instead of an operator, but apparently GCC thinks it should be calling a different one in that case. I'm also mystified why operator=() doesn't work in the first place. Null defines the same set of operator=() as it defines ctors. If the compiler can find a suitable ctor to call, it should be able to find a suitable operator. This feels like one of those weird C++ corner cases, where you have to be a language lawyer to understand what declaration you're supposed to provide so the compiler doesn't run into ambiguous call situations. If anyone can figure it out and provide a patch, it'll likely go in without much fuss, Null being a template and all. (Template changes don't affect the library ABI.)