24#ifndef quantlib_composite_quote_hpp
25#define quantlib_composite_quote_hpp
39 template <
class BinaryFunction>
63 template <
class BinaryFunction>
66 const BinaryFunction&
f) {
72 template <
class BinaryFunction>
75 const BinaryFunction&
f)
76 : element1_(
std::move(element1)), element2_(
std::move(element2)),
f_(
f) {
81 template <
class BinaryFunction>
83 QL_ENSURE(isValid(),
"invalid CompositeQuote");
84 return f_(element1_->value(),element2_->value());
87 template <
class BinaryFunction>
89 return !element1_.empty() && !element2_.empty() &&
90 element1_->isValid() && element2_->isValid();
93 template <
class BinaryFunction>
market element whose value depends on two other market element
Handle< Quote > element1_
Handle< Quote > element2_
CompositeQuote(Handle< Quote > element1, Handle< Quote > element2, const BinaryFunction &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_
Classes and functions for error handling.
#define QL_ENSURE(condition, message)
throw an error if the given post-condition is not verified
Globally accessible relinkable pointer.
CompositeQuote< BinaryFunction > makeCompositeQuote(const Handle< Quote > &element1, const Handle< Quote > &element2, const BinaryFunction &f)
creator method
purely virtual base class for market observables