Boost logo

Boost :

From: Andrey Melnikov (melnikov_at_[hidden])
Date: 2005-07-15 11:30:32


Rob Stewart wrote:
> From: "Jost, Andrew" <Andrew_Jost_at_[hidden]>
>
>>But you're assuming that we have control over the library. That's
>>probably the exception rather than the rule in real life.
>
> If you can change the library to use an adaptor for an optional,
> why can't you change the library to use the optional directly?
>

Adapters work outside the library and don't require any changes to the
library. Library requires underlying values, and with the adapter it
gets them automagically. The library doesn't know anything about
Optional and adapters, library clients do.

>>There is a key advantage in the example with
>>adapters because the adapter is a function object. In that respect, the
>>door has been flung open to many templated constructs that are more
>>difficlt with the ?: operator. For example, a boost::transform_iterator
>>could be created with the adapter to automatically access the underlying
>>objects in a sequence.
>
>
> Hmmm. This reminds me of using the STL algorithms before having
> Boost.Lambda, Boost.Bind, etc. Without a library of predefined
> function objects that perform useful, reusable adaptations, or a
> lambda approach to creating the adapters, one winds up separating
> the value extraction logic from the context in which it is used.

Do you mean that efforts to create a custom function object aren't worth
of the result, and most people will just end with using IFs and refusing
to create an adapter or a function object for an existing adapter?

So far I think we can live with just Optional and
OptionalWithDefaultValue. A default value is needed very often.

Andrey


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