26#ifndef quantlib_derived_quote_hpp
27#define quantlib_derived_quote_hpp
39 template <
class UnaryFunction>
58 template <
class UnaryFunction>
60 const UnaryFunction&
f) {
65 template <
class UnaryFunction>
67 : element_(
std::move(element)),
f_(
f) {
71 template <
class UnaryFunction>
73 QL_ENSURE(isValid(),
"invalid DerivedQuote");
74 return f_(element_->value());
77 template <
class UnaryFunction>
79 return !element_.empty() && element_->isValid();
82 template <
class UnaryFunction>
market quote whose value depends on another quote
DerivedQuote(Handle< Quote > element, const UnaryFunction &f)
Real value() const override
returns the current value
bool isValid() const override
returns true if the Quote holds a valid value
Shared handle to an observable.
Object that gets notified when a given observable changes.
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
purely virtual base class for market observables
ext::function< Real(Real)> f_
#define QL_ENSURE(condition, message)
throw an error if the given post-condition is not verified
Globally accessible relinkable pointer.
DerivedQuote< UnaryFunction > makeDerivedQuote(const Handle< Quote > &element, const UnaryFunction &f)
creator method
purely virtual base class for market observables