Boost logo

Boost :

Subject: Re: [boost] [optional] Specializing optional to save space
From: David Stone (david_at_[hidden])
Date: 2015-09-28 19:29:51


On Mon, Sep 28, 2015 at 4:02 PM, Sam Kellett <samkellett_at_[hidden]> wrote:

> > this applies to any possible value of int -- so therefore somebody,
> > somewhere will have a valid int that is an optional and some purely
> genetic
> > code will get it wrong
> >
>
> er.. generic.. doh
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>

This is more in line with the compact_optional proposal in the other
thread. The specialization is only created for a value that cannot
otherwise exist for your type. Any magic value of int is a valid int value,
so there would not be a specialization of optional<int> that makes, say, -1
invalid. In this proposal, there is absolutely nothing the user can do
other than sizeof that lets them tell the difference (and they won't run
out of memory as quickly from allocating a bunch of them).


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