
Andrey Melnikov <melnikov@simplexsoft.com> writes:
Rob Stewart wrote:
From: "Jost, Andrew" <Andrew_Jost@mentor.com>
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.
FYI, I might tend to use a dual_state object that either yields a contained _reference_ or the result of invoking a function, because you usually don't want to pay for copy construction of a contained object if you don't have to, and it feels nonuniform to have lightweight copy only when the default is going to be used. -- Dave Abrahams Boost Consulting www.boost-consulting.com