Wrapping QuantLib::VanillaSwap class
Posted by Raj Subramani on Mar 31, 2017; 8:26am
URL: http://quantlib.414.s1.nabble.com/Wrapping-QuantLib-VanillaSwap-class-tp18163.html
I have to maintain dimensions such as tradeid, counterpartyname and various other parameters. I have therefore created a class called PlainVanillaSpotSwap with the header file - as follows:
PlainVanillaSpotSwap.h
class PlainVanillaSpotSwap
{
private:
std::string _tradeid;
...
...
public:
...
boost::shared_ptr<VanillaSwap> qlSwap;
}
My problem is I do not know how to lazy instantiate this shared pointer called qlSwap.
At the moment inside the constructor for PlainVanillaSpotSwap - I am doing
boost::shared_ptr<VanillaSwap> _qlSwap(new VanillaSwap(swapType, nominal, ... floatingLegDayCounter));
Obviously - _qlSwap is a local VanillaSwap object created inside the constructor and then I set
qlSwap = _qlSwap;
I would like to avoid this and initialize qlSwap in the constructor itself.
Its been a while since I coded in C++ so please be gentle!