Boost logo

Boost :

Subject: Re: [boost] [optional] Specializing optional to save space
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2015-09-27 18:11:13


On 28.09.2015 00:47, Nevin Liber wrote:
> On 27 September 2015 at 16:19, Andrey Semashev <andrey.semashev_at_[hidden]>
> wrote:
>>
>> I got the impression that the OP intended that the specialized optional<>
>> still controlled the lifetime of the adopted object the way it does now.
>> The proposed change basically offloads engagement checking to a
>> user-specializable trait but really nothing more than that.
>>
>
> His example was to use a specific value of std::string::size() as a
> sentinel. How does that work with his specialized optional if the
> specialization is orthogonal to lifetime control?

Excerpt from the OP:

> For instance, for common implementations of std::string you cannot
> have std::string::size() ==
> std::numeric_limits<std::string::size_type>::max() *. We can take
> advantage of this if our std::string implementation stores the
> capacity as an integer value, rather than a pointer to the end of the
> storage.

 From this I gather that the intention is to use the storage from the
capacity member of std::string to store the discriminator. I assume, the
std::string object has to be not constructed for this as in no way you
can create such string through its interface. But maybe I'm seeing too
much here - I'll let David clarify this himself.


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