Subject: Re: [boost] sqlpp11, 3rd iteration
From: Roland Bock (rbock_at_[hidden])
Date: 2014-08-18 14:23:28


On 2014-08-18 19:58, Adam Wulkiewicz wrote:
> Hi Roland,
>
> Roland Bock wrote:
>> _NULL handling:_
>> Enabled by the restructured code and spurred by the library quince by
>> Michael Shepanski, sqlpp11 can now calculate which result fields can or
>> cannot be NULL.
>>
>> Speaking of which, handling NULL for result values has been discussed a
>> lot. The library now has compile-time configurable behavior, you can
>> choose between an std::optional-like interface and mapping NULL to the
>> trivial value of the result type, e.g. 0 for numbers or "" for strings,
>> see also https://github.com/rbock/sqlpp11/wiki/NULL
>
> You wrote in the docs:
>
> <cite>
> One often discussed alternative would be boost::optional or (in the
> future) std::optional. There is one drawbacks (correct me if I am
> wrong, please):|
> optional| cannot be used for binding result values because it is
> unclear whether there already is a value to bind to.
> </cite>
>
> What do you mean by that?
>
> If I understand correctly, you have in mind returning
> boost::optional<> from a function. It's ok to do it, the value is
> stored in optional and deep copies are done if needed.
> http://www.boost.org/doc/libs/1_56_0/libs/optional/doc/html/boost_optional/tutorial/design_overview.html
>
> http://www.boost.org/doc/libs/1_56_0/libs/optional/doc/html/boost_optional/quick_start.html#boost_optional.quick_start.optional_return_values
>
>
> Regards,
> Adam

Adam,

I was referring to what some sql libraries do, e.g. Mysql's C interface:
They take pointers to some memory and then write result fields to those
memory blocks, see for instance
http://dev.mysql.com/doc/refman/5.7/en/mysql-stmt-bind-result.html

I don't know if that would be legal to do with the value in optional.

Regards,

Roland