Boost logo

Boost :

Subject: Re: [boost] sqlpp11, 3rd iteration
From: Adam Wulkiewicz (adam.wulkiewicz_at_[hidden])
Date: 2014-08-18 13:58:59


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


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk