Boost logo

Boost :

Subject: Re: [boost] compact_optional -- prompting interest
From: Marcel Raad (raad_at_[hidden])
Date: 2015-09-25 11:55:19

Andrey Semashev-2 wrote
> 1. You chose not to provide relational operators for compact_optional
> because you don't know how to order 'empty' values. I think you don't
> have to make that decision and simply forward the call to the underlying
> type. I mean, you always have the stored object constructed in some state
> and as long as it implements operators you can always use them.

This is exactly the problem I sometimes have with Boost.Optional: in some
use cases, I want the compiler to remind me that my special value is special
and always has to be checked explicitly instead of assuming it's always the
lowest possible value. That doesn't apply to operator== and operator!=, of

Andrey Semashev-2 wrote
> 5. A suggestion: add evp_zero and evp_empty policies. The first uses
> literal zero as the special value and can be used with numeric (integer
> and fp) and pointer types. The second uses a default constructed value as
> the magic value and a member empty() function to test for magic value.
> This could be useful with containers, strings and ranges.

+1, evp_empy would also be useful for a lot of other custom classes I've

View this message in context:
Sent from the Boost - Dev mailing list archive at

Boost list run by bdawes at, gregod at, cpdaniel at, john at