Boost logo

Boost :

From: Edward Diener (eddielee_at_[hidden])
Date: 2003-03-25 17:19:23


Rozental, Gennadiy wrote:
>> Therefore to justify
>> boost::optional as a key in an associative container, as
>> opposed to its
>> direct type, I believe one has to justify a situation where
>> the "non-actual"
>> value is really being used as a key.
>
> Let say I have mapping of state to action. Now I want to support the
> case where current state is undefined. So I am using optional<state>
> as a key. Does this example fit for the situation?

It fits the situation. A good example. OK, I'm sold. <g> My imagination on
this was too limited. I can see where one can use the undefined value along
with a number of defined values as keys in containers or as values in a
sorted container, both needing the operator < . I assume that operator <
would of course have undefined values always false when compared against
another undefined value as being <. The decision that needs to be made is
how an undefined value compares against defined values. Is the undefined
value always < all defined values, or is the undefined value always > all
defined values, or is it user decided via some boolean switch.


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