Subject: Re: [boost] sqlpp11, 3rd iteration
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2014-08-20 02:50:36
On 20/08/2014 18:30, Michael Shepanski wrote:
> On 20/08/2014 9:54 AM, Gavin Lambert wrote:
>> If you made your type implicitly convertible to optional and back,
>> that ought to make everybody happy. :) (Well, except maybe the folks
>> who hate implicit conversions, but they're never happy.)
> I love implicit conversions. I love implicitly converting const char*
> to std::string. I love implicitly converting std::string to
> boost::optional<std::string>. So imagine my heartache when they told me
> I couldn't implicitly convert const char* to boost::optional<string>.
> What, you mean I can't really use const char * /wherever/ I can use
> I feel that I'm in for more tears if we have an implicit conversion from
> boost::optional to something else.
Two implicit conversions is double-jeopardy, partly because that would
bring an infinite cycle into scope.
Yes, it does mean that you have to be a little more explicit sometimes,
but I'm unconvinced that would be a real problem in practice.
Methods in the sqlpp interface would accept a some_other_optional<T>,
which means that you could pass them one of those directly, or a
boost::optional<T> (via some_other_optional<T> implicit constructor), or
a T (via some_other_optional<T> implicit constructor).
Note that the latter cannot implicitly be constructed as a
boost::optional<T> first because that would require two implicit
conversions. So everything should just naturally work.
(And you can't use const char* wherever you use std::string anyway --
"a" + "b" is a very different thing from std::string("a") + "b".)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk