[prev in list] [next in list] [prev in thread] [next in thread]
List: boost
Subject: Re: [boost] compact_optional -- prompting interest
From: Andrzej Krzemienski <akrzemi1 () gmail ! com>
Date: 2015-09-30 12:14:58
Message-ID: CAOenAXhW_mT8qF5sgs-GCQjTa2zXgO_2eSH4crg2KJp2M84ajw () mail ! gmail ! com
[Download RAW message or body]
2015-09-27 13:00 GMT+02:00 Matt Calabrese <rivorus@gmail.com>:
> On Sat, Sep 26, 2015 at 1:12 PM, Nevin Liber <nevin@eviloverlord.com>
> wrote:
> >
> > I'm strongly against the word "optional" appearing the name, for the
> > following reasons:
> >
> >
> > - optional<int> allows me to use every single value that can be stored
> > in an int. This doesn't.
> > - optional<string> allows one to shorten the lifetime of the string it
> > holds. This doesn't.
> > - optional<T> has a nothrow default constructor. This doesn't.
> >
> > At best, it resembles optional only superficially. Please give it a
> > different name.
>
>
> This. However, I do think that there is a place for a separate
> intrusive_optional as well, though the empty value should not be a valid
> value of the type, but rather, just be able to take advantage of its
> storage, and the type should not be constructed while the in the empty
> state. I.E. an optional reference only takes up the size of a pointer
> because it uses the "0" value for empty. Similarly, any type that contains
> a reference (or a pointer that cannot be null) also can take advantage of
> this by way of an intrusive optional. The user would have to provide a
> predicate that operates on the raw storage of the value, and access it in a
> way that is well-formed whether the object is constructed there or not, so
> it is a little bit trickier to specify properly.
I have now implemented this capability in compact_optional. See the related
docs section:
https://github.com/akrzemi1/compact_optional/blob/master/documentation.md#using-pod-storage-for-empty-value
Regards,
&rzej
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic