Warren Young wrote:
> Byrial Jensen wrote:
>
>> I often store booleans (MySQL type BOOL, alias for TINYINT(1)). So it
>> would be very nice to have an automatic conversion from ColData to bool
>
> Unless I'm greatly mistaken, this would be a pretty trivial thing to
> patch; 3 lines in coldata.h, probably. Congratulations, you're
> volunteered. :)
You are of course right that it can be done in 3 lines. It would herpaps
be more elegant to make a new variant of mysql_convert() instead of
relying on C++'s implicit conversion from int to bool, but here it is.
Best regards,
Byrial
--- coldata.h~ 2005-06-01 20:36:20.574670267 +0200
+++ coldata.h 2005-06-01 20:37:45.324233098 +0200
@@ -205,6 +205,9 @@ public:
/// \brief Converts this object's string data to a double
operator double() const { return conv(static_cast<double>(0)); }
+ /// \brief Converts this object's string data to a bool
+ operator bool() const { return conv(0); }
+
template <class T, class B> operator Null<T, B>() const;
};