On 25.9.2015. 16:35, Andrzej Krzemienski wrote:
Hi Everyone, I would like to inquire if there would be an interest in Boost in another library for storing optional objects, but working under different design goals.
Compact optional T has (or can have) the same sizeof as T. It uses one indicated value of T to represent the "empty" (or "singular") value. You can declare it like this:
compact_optional
> oi; <...> It is not meant to be an alternative to Boost.Optional: it targets a different application space.
Hi Andrzej,
+1 @ the improvement (as just one of the many improvements and 'polishes' long
overdue for boost::optional)
-1 @ making it a new/different class template
If the improvement/change does not prevent providing the same interface and
semantics as optional while offering same-or-better efficiency - then it's just
simply better.
IOW, I'm all for adding a new 'policies' template parameter (properly defaulted
for backwards compatibility) to optional (or perhaps trait(s) classes instead of
a new template parameter - w can debated that ;).
The one-size-fits-all shared_ptr and
make-every-one-pay-for-everything-no-matter-how-fat-it-is iostreams, filesystem,
Qt,... logic is IMNHO so C#/Java like and so 'unworthy' of C++...so can we
please remove that mentality from optional before it gets into the standard?
As the discussions and (already implemented) proposals from a couple of years
back show, eg.:
http://lists.boost.org/Archives/boost/2012/01/189857.php
http://lists.boost.org/Archives/boost/2009/10/156750.php
there are many other possible and needed improvements for optional and it is not
nearly all about memory efficiency. There are many codegen issues, for example
if I work with floats that must never be NaN, I'd want to wrap them in
optional