Boost logo

Boost :

Subject: Re: [boost] [optional] Suggestion for adding an optional_number class
From: Hans Dembinski (hans.dembinski_at_[hidden])
Date: 2017-07-28 10:03:12


> On 26. Jul 2017, at 15:07, Viktor Sehr <viktor.sehr_at_[hidden]> wrote:
>
> Thanks for your critique, as I see boost::markable is exactly what I was intended as it is a little bit more generalized.
>
> Regarding the throwing, I intended the throw when assigned the mark value to be an "equivalent" to a assert, as I imagined the intention of assigning an uninitalized value is more clear if forced to used "val = {}" or "val.reset();", meaning it would be more of a drop-in replacement for boost::optional.

For what it's worth, I don't understand the critique in this thread. I thought that boost::markable was a neat idea and since people already use special integer values to indicate errors already, see std::string::npos, why not make a nice template for this use case that makes this (mis)use of special integer values more obvious and less error prone.


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