File: _replication_8cpp-example.html

package info (click to toggle)
quantlib-refman-html 1.20-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 103,140 kB
  • sloc: javascript: 13,408; makefile: 35
file content (449 lines) | stat: -rw-r--r-- 46,297 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.20"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>QuantLib: Replication.cpp</title>
<link href='https://fonts.googleapis.com/css?family=Merriweather+Sans:800' rel='stylesheet' type='text/css'>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
</script>
<script type="text/javascript" async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="quantlibextra.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname"><a href="http://quantlib.org">
       <img alt="QuantLib" src="QL-title.jpg"></a>
   <div id="projectbrief">A free/open-source library for quantitative finance</div>
   <div id="projectnumber">Reference manual - version 1.20</div>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.20 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">Replication.cpp</div>  </div>
</div><!--header-->
<div class="contents">
<p>This example uses the CompositeInstrument class to statically replicate a down-and-out barrier options.</p>
<div class="fragment"><div class="line"><span class="comment">/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */</span></div>
<div class="line"> </div>
<div class="line"><span class="comment">/*  This example showcases the CompositeInstrument class. Such class</span></div>
<div class="line"><span class="comment">    is used to build a static replication of a down-and-out barrier</span></div>
<div class="line"><span class="comment">    option, as outlined in Section 10.2 of Mark Joshi&#39;s &quot;The Concepts</span></div>
<div class="line"><span class="comment">    and Practice of Mathematical Finance&quot; to which we refer the</span></div>
<div class="line"><span class="comment">    reader.</span></div>
<div class="line"><span class="comment">*/</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;ql/qldefines.hpp&gt;</span></div>
<div class="line"><span class="preprocessor">#ifdef BOOST_MSVC</span></div>
<div class="line"><span class="preprocessor">#  include &lt;ql/auto_link.hpp&gt;</span></div>
<div class="line"><span class="preprocessor">#endif</span></div>
<div class="line"><span class="preprocessor">#include &lt;ql/instruments/compositeinstrument.hpp&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;ql/instruments/barrieroption.hpp&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;ql/instruments/europeanoption.hpp&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;ql/pricingengines/barrier/analyticbarrierengine.hpp&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;ql/pricingengines/vanilla/analyticeuropeanengine.hpp&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;ql/exercise.hpp&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;ql/termstructures/yield/flatforward.hpp&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;ql/termstructures/volatility/equityfx/blackconstantvol.hpp&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;ql/quotes/simplequote.hpp&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;ql/time/calendars/nullcalendar.hpp&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;iostream&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;iomanip&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="keyword">using namespace </span><a class="code" href="namespace_quant_lib.html">QuantLib</a>;</div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#if defined(QL_ENABLE_SESSIONS)</span></div>
<div class="line"><span class="keyword">namespace </span><a class="code" href="namespace_quant_lib.html">QuantLib</a> {</div>
<div class="line"> </div>
<div class="line">    ThreadKey sessionId() { <span class="keywordflow">return</span> 0; }</div>
<div class="line"> </div>
<div class="line">}</div>
<div class="line"><span class="preprocessor">#endif</span></div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span>, <span class="keywordtype">char</span>* []) {</div>
<div class="line"> </div>
<div class="line">    <span class="keywordflow">try</span> {</div>
<div class="line"> </div>
<div class="line">        std::cout &lt;&lt; std::endl;</div>
<div class="line"> </div>
<div class="line">        <a name="_a0"></a><a class="code" href="class_quant_lib_1_1_date.html" title="Concrete date class.">Date</a> today(29, May, 2006);</div>
<div class="line">        <a name="a1"></a><a class="code" href="class_quant_lib_1_1_singleton.html#ab7455b7e1235d292c444095842349291" title="access to the unique instance">Settings::instance</a>().evaluationDate() = today;</div>
<div class="line"> </div>
<div class="line">        <span class="comment">// the option to replicate</span></div>
<div class="line">        Barrier::Type barrierType = Barrier::DownOut;</div>
<div class="line">        <a name="a2"></a><a class="code" href="group__types.html#ga4bdf4bfe76b9ffa6fa64c47d8bfa0c78" title="real number">Real</a> barrier = 70.0;</div>
<div class="line">        <a class="code" href="group__types.html#ga4bdf4bfe76b9ffa6fa64c47d8bfa0c78" title="real number">Real</a> rebate = 0.0;</div>
<div class="line">        Option::Type type = Option::Put;</div>
<div class="line">        <a class="code" href="group__types.html#ga4bdf4bfe76b9ffa6fa64c47d8bfa0c78" title="real number">Real</a> underlyingValue = 100.0;</div>
<div class="line">        ext::shared_ptr&lt;SimpleQuote&gt; underlying(</div>
<div class="line">                                            <span class="keyword">new</span> <a name="_a3"></a><a class="code" href="class_quant_lib_1_1_simple_quote.html" title="market element returning a stored value">SimpleQuote</a>(underlyingValue));</div>
<div class="line">        <a class="code" href="group__types.html#ga4bdf4bfe76b9ffa6fa64c47d8bfa0c78" title="real number">Real</a> strike = 100.0;</div>
<div class="line">        ext::shared_ptr&lt;SimpleQuote&gt; riskFreeRate(<span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_simple_quote.html" title="market element returning a stored value">SimpleQuote</a>(0.04));</div>
<div class="line">        ext::shared_ptr&lt;SimpleQuote&gt; <a name="a4"></a><a class="code" href="group__manips.html#gac402ef7c87f63f7c603ee87210b5750c" title="output volatilities as percentages">volatility</a>(<span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_simple_quote.html" title="market element returning a stored value">SimpleQuote</a>(0.20));</div>
<div class="line">        <a class="code" href="class_quant_lib_1_1_date.html" title="Concrete date class.">Date</a> maturity = today + 1*Years;</div>
<div class="line"> </div>
<div class="line">        std::cout &lt;&lt; std::endl ;</div>
<div class="line"> </div>
<div class="line">        <span class="comment">// write column headings</span></div>
<div class="line">        <a class="code" href="group__types.html#gaf38bdb4c54463b1f456655efa95b5c77" title="size of a container">Size</a> widths[] = { 45, 15, 15 };</div>
<div class="line">        <a class="code" href="group__types.html#gaf38bdb4c54463b1f456655efa95b5c77" title="size of a container">Size</a> totalWidth = widths[0]+widths[1]+widths[2];</div>
<div class="line">        std::string rule(totalWidth, <span class="charliteral">&#39;-&#39;</span>), dblrule(totalWidth, <span class="charliteral">&#39;=&#39;</span>);</div>
<div class="line"> </div>
<div class="line">        std::cout &lt;&lt; dblrule &lt;&lt; std::endl;</div>
<div class="line">        std::cout &lt;&lt; <span class="stringliteral">&quot;Initial market conditions&quot;</span> &lt;&lt; std::endl;</div>
<div class="line">        std::cout &lt;&lt; dblrule &lt;&lt; std::endl;</div>
<div class="line">        std::cout &lt;&lt; std::setw(widths[0]) &lt;&lt; std::left &lt;&lt; <span class="stringliteral">&quot;Option&quot;</span></div>
<div class="line">                  &lt;&lt; std::setw(widths[1]) &lt;&lt; std::left &lt;&lt; <span class="stringliteral">&quot;NPV&quot;</span></div>
<div class="line">                  &lt;&lt; std::setw(widths[2]) &lt;&lt; std::left &lt;&lt; <span class="stringliteral">&quot;Error&quot;</span></div>
<div class="line">                  &lt;&lt; std::endl;</div>
<div class="line">        std::cout &lt;&lt; rule &lt;&lt; std::endl;</div>
<div class="line"> </div>
<div class="line">        <span class="comment">// bootstrap the yield/vol curves</span></div>
<div class="line">        <a name="_a5"></a><a class="code" href="class_quant_lib_1_1_day_counter.html" title="day counter class">DayCounter</a> dayCounter = <a name="_a6"></a><a class="code" href="class_quant_lib_1_1_actual365_fixed.html" title="Actual/365 (Fixed) day count convention.">Actual365Fixed</a>();</div>
<div class="line">        <a name="_a7"></a><a class="code" href="class_quant_lib_1_1_handle.html" title="Shared handle to an observable.">Handle&lt;Quote&gt;</a> h1(riskFreeRate);</div>
<div class="line">        <a class="code" href="class_quant_lib_1_1_handle.html" title="Shared handle to an observable.">Handle&lt;Quote&gt;</a> h2(<a class="code" href="group__manips.html#gac402ef7c87f63f7c603ee87210b5750c" title="output volatilities as percentages">volatility</a>);</div>
<div class="line">        <a name="_a8"></a><a class="code" href="class_quant_lib_1_1_handle.html">Handle&lt;YieldTermStructure&gt;</a> flatRate(</div>
<div class="line">            ext::shared_ptr&lt;YieldTermStructure&gt;(</div>
<div class="line">                                  <span class="keyword">new</span> <a name="_a9"></a><a class="code" href="class_quant_lib_1_1_flat_forward.html" title="Flat interest-rate curve.">FlatForward</a>(0, <a name="_a10"></a><a class="code" href="class_quant_lib_1_1_null_calendar.html" title="Calendar for reproducing theoretical calculations.">NullCalendar</a>(),</div>
<div class="line">                                                  h1, dayCounter)));</div>
<div class="line">        <a class="code" href="class_quant_lib_1_1_handle.html" title="Shared handle to an observable.">Handle&lt;BlackVolTermStructure&gt;</a> flatVol(</div>
<div class="line">            ext::shared_ptr&lt;BlackVolTermStructure&gt;(</div>
<div class="line">                               <span class="keyword">new</span> <a name="_a11"></a><a class="code" href="class_quant_lib_1_1_black_constant_vol.html" title="Constant Black volatility, no time-strike dependence.">BlackConstantVol</a>(0, <a class="code" href="class_quant_lib_1_1_null_calendar.html" title="Calendar for reproducing theoretical calculations.">NullCalendar</a>(),</div>
<div class="line">                                                    h2, dayCounter)));</div>
<div class="line"> </div>
<div class="line">        <span class="comment">// instantiate the option</span></div>
<div class="line">        ext::shared_ptr&lt;Exercise&gt; exercise(</div>
<div class="line">                                         <span class="keyword">new</span> <a name="_a12"></a><a class="code" href="class_quant_lib_1_1_european_exercise.html" title="European exercise.">EuropeanExercise</a>(maturity));</div>
<div class="line">        ext::shared_ptr&lt;StrikedTypePayoff&gt; payoff(</div>
<div class="line">                                        <span class="keyword">new</span> <a name="_a13"></a><a class="code" href="class_quant_lib_1_1_plain_vanilla_payoff.html" title="Plain-vanilla payoff.">PlainVanillaPayoff</a>(type, strike));</div>
<div class="line"> </div>
<div class="line">        ext::shared_ptr&lt;BlackScholesProcess&gt; bsProcess(</div>
<div class="line">                            <span class="keyword">new</span> <a name="_a14"></a><a class="code" href="class_quant_lib_1_1_black_scholes_process.html" title="Black-Scholes (1973) stochastic process.">BlackScholesProcess</a>(<a class="code" href="class_quant_lib_1_1_handle.html" title="Shared handle to an observable.">Handle&lt;Quote&gt;</a>(underlying),</div>
<div class="line">                                                    flatRate, flatVol));</div>
<div class="line"> </div>
<div class="line">        ext::shared_ptr&lt;PricingEngine&gt; barrierEngine(</div>
<div class="line">                                        <span class="keyword">new</span> <a name="_a15"></a><a class="code" href="class_quant_lib_1_1_analytic_barrier_engine.html" title="Pricing engine for barrier options using analytical formulae.">AnalyticBarrierEngine</a>(bsProcess));</div>
<div class="line">        ext::shared_ptr&lt;PricingEngine&gt; europeanEngine(</div>
<div class="line">                                       <span class="keyword">new</span> <a name="_a16"></a><a class="code" href="class_quant_lib_1_1_analytic_european_engine.html" title="Pricing engine for European vanilla options using analytical formulae.">AnalyticEuropeanEngine</a>(bsProcess));</div>
<div class="line"> </div>
<div class="line">        <a name="_a17"></a><a class="code" href="class_quant_lib_1_1_barrier_option.html" title="Barrier option on a single asset.">BarrierOption</a> referenceOption(barrierType, barrier, rebate,</div>
<div class="line">                                      payoff, exercise);</div>
<div class="line">        referenceOption.setPricingEngine(barrierEngine);</div>
<div class="line"> </div>
<div class="line">        <a class="code" href="group__types.html#ga4bdf4bfe76b9ffa6fa64c47d8bfa0c78" title="real number">Real</a> referenceValue = referenceOption.NPV();</div>
<div class="line"> </div>
<div class="line">        std::cout &lt;&lt; std::setw(widths[0]) &lt;&lt; std::left</div>
<div class="line">                  &lt;&lt; <span class="stringliteral">&quot;Original barrier option&quot;</span></div>
<div class="line">                  &lt;&lt; std::fixed</div>
<div class="line">                  &lt;&lt; std::setw(widths[1]) &lt;&lt; std::left &lt;&lt; referenceValue</div>
<div class="line">                  &lt;&lt; std::setw(widths[2]) &lt;&lt; std::left &lt;&lt; <span class="stringliteral">&quot;N/A&quot;</span></div>
<div class="line">                  &lt;&lt; std::endl;</div>
<div class="line"> </div>
<div class="line">        <span class="comment">// Replicating portfolios</span></div>
<div class="line">        <a name="_a18"></a><a class="code" href="class_quant_lib_1_1_composite_instrument.html" title="Composite instrument">CompositeInstrument</a> portfolio1, portfolio2, portfolio3;</div>
<div class="line"> </div>
<div class="line">        <span class="comment">// Final payoff first (the same for all portfolios):</span></div>
<div class="line">        <span class="comment">// as shown in Joshi, a put struck at K...</span></div>
<div class="line">        ext::shared_ptr&lt;Instrument&gt; put1(</div>
<div class="line">                                        <span class="keyword">new</span> <a name="_a19"></a><a class="code" href="class_quant_lib_1_1_european_option.html" title="European option on a single asset.">EuropeanOption</a>(payoff, exercise));</div>
<div class="line">        put1-&gt;setPricingEngine(europeanEngine);</div>
<div class="line">        portfolio1.<a name="a20"></a><a class="code" href="class_quant_lib_1_1_composite_instrument.html#a17f4129206e9cd104423285c9bb7457e" title="adds an instrument to the composite">add</a>(put1);</div>
<div class="line">        portfolio2.<a class="code" href="class_quant_lib_1_1_composite_instrument.html#a17f4129206e9cd104423285c9bb7457e" title="adds an instrument to the composite">add</a>(put1);</div>
<div class="line">        portfolio3.<a class="code" href="class_quant_lib_1_1_composite_instrument.html#a17f4129206e9cd104423285c9bb7457e" title="adds an instrument to the composite">add</a>(put1);</div>
<div class="line">        <span class="comment">// ...minus a digital put struck at B of notional K-B...</span></div>
<div class="line">        ext::shared_ptr&lt;StrikedTypePayoff&gt; digitalPayoff(</div>
<div class="line">                          <span class="keyword">new</span> <a name="_a21"></a><a class="code" href="class_quant_lib_1_1_cash_or_nothing_payoff.html" title="Binary cash-or-nothing payoff.">CashOrNothingPayoff</a>(Option::Put, barrier, 1.0));</div>
<div class="line">        ext::shared_ptr&lt;Instrument&gt; digitalPut(</div>
<div class="line">                                 <span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_european_option.html" title="European option on a single asset.">EuropeanOption</a>(digitalPayoff, exercise));</div>
<div class="line">        digitalPut-&gt;setPricingEngine(europeanEngine);</div>
<div class="line">        portfolio1.<a name="a22"></a><a class="code" href="class_quant_lib_1_1_composite_instrument.html#a5d1575f5d5bd36deb2aafbeb785ceeb7" title="shorts an instrument from the composite">subtract</a>(digitalPut, strike-barrier);</div>
<div class="line">        portfolio2.<a class="code" href="class_quant_lib_1_1_composite_instrument.html#a5d1575f5d5bd36deb2aafbeb785ceeb7" title="shorts an instrument from the composite">subtract</a>(digitalPut, strike-barrier);</div>
<div class="line">        portfolio3.<a class="code" href="class_quant_lib_1_1_composite_instrument.html#a5d1575f5d5bd36deb2aafbeb785ceeb7" title="shorts an instrument from the composite">subtract</a>(digitalPut, strike-barrier);</div>
<div class="line">        <span class="comment">// ...minus a put option struck at B.</span></div>
<div class="line">        ext::shared_ptr&lt;StrikedTypePayoff&gt; lowerPayoff(</div>
<div class="line">                                <span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_plain_vanilla_payoff.html" title="Plain-vanilla payoff.">PlainVanillaPayoff</a>(Option::Put, barrier));</div>
<div class="line">        ext::shared_ptr&lt;Instrument&gt; put2(</div>
<div class="line">                                   <span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_european_option.html" title="European option on a single asset.">EuropeanOption</a>(lowerPayoff, exercise));</div>
<div class="line">        put2-&gt;setPricingEngine(europeanEngine);</div>
<div class="line">        portfolio1.<a class="code" href="class_quant_lib_1_1_composite_instrument.html#a5d1575f5d5bd36deb2aafbeb785ceeb7" title="shorts an instrument from the composite">subtract</a>(put2);</div>
<div class="line">        portfolio2.<a class="code" href="class_quant_lib_1_1_composite_instrument.html#a5d1575f5d5bd36deb2aafbeb785ceeb7" title="shorts an instrument from the composite">subtract</a>(put2);</div>
<div class="line">        portfolio3.<a class="code" href="class_quant_lib_1_1_composite_instrument.html#a5d1575f5d5bd36deb2aafbeb785ceeb7" title="shorts an instrument from the composite">subtract</a>(put2);</div>
<div class="line"> </div>
<div class="line">        <span class="comment">// Now we use puts struck at B to kill the value of the</span></div>
<div class="line">        <span class="comment">// portfolio on a number of points (B,t).  For the first</span></div>
<div class="line">        <span class="comment">// portfolio, we&#39;ll use 12 dates at one-month&#39;s distance.</span></div>
<div class="line">        <a name="a23"></a><a class="code" href="group__types.html#gab9c87440c314438e51a899a03d2442d0" title="integer number">Integer</a> i;</div>
<div class="line">        <span class="keywordflow">for</span> (i=12; i&gt;=1; i--) {</div>
<div class="line">            <span class="comment">// First, we instantiate the option...</span></div>
<div class="line">            <a class="code" href="class_quant_lib_1_1_date.html" title="Concrete date class.">Date</a> innerMaturity = today + i*Months;</div>
<div class="line">            ext::shared_ptr&lt;Exercise&gt; innerExercise(</div>
<div class="line">                                         <span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_european_exercise.html" title="European exercise.">EuropeanExercise</a>(innerMaturity));</div>
<div class="line">            ext::shared_ptr&lt;StrikedTypePayoff&gt; innerPayoff(</div>
<div class="line">                                <span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_plain_vanilla_payoff.html" title="Plain-vanilla payoff.">PlainVanillaPayoff</a>(Option::Put, barrier));</div>
<div class="line">            ext::shared_ptr&lt;Instrument&gt; putn(</div>
<div class="line">                              <span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_european_option.html" title="European option on a single asset.">EuropeanOption</a>(innerPayoff, innerExercise));</div>
<div class="line">            putn-&gt;setPricingEngine(europeanEngine);</div>
<div class="line">            <span class="comment">// ...second, we evaluate the current portfolio and the</span></div>
<div class="line">            <span class="comment">// latest put at (B,t)...</span></div>
<div class="line">            <a class="code" href="class_quant_lib_1_1_date.html" title="Concrete date class.">Date</a> killDate = today + (i-1)*Months;</div>
<div class="line">            <a class="code" href="class_quant_lib_1_1_singleton.html#ab7455b7e1235d292c444095842349291" title="access to the unique instance">Settings::instance</a>().evaluationDate() = killDate;</div>
<div class="line">            underlying-&gt;setValue(barrier);</div>
<div class="line">            <a class="code" href="group__types.html#ga4bdf4bfe76b9ffa6fa64c47d8bfa0c78" title="real number">Real</a> portfolioValue = portfolio1.<a name="a24"></a><a class="code" href="class_quant_lib_1_1_instrument.html#a4f791921f063f3ea19bd6efa9ceb4892" title="returns the net present value of the instrument.">NPV</a>();</div>
<div class="line">            <a class="code" href="group__types.html#ga4bdf4bfe76b9ffa6fa64c47d8bfa0c78" title="real number">Real</a> putValue = putn-&gt;NPV();</div>
<div class="line">            <span class="comment">// ...finally, we estimate the notional that kills the</span></div>
<div class="line">            <span class="comment">// portfolio value at that point...</span></div>
<div class="line">            <a class="code" href="group__types.html#ga4bdf4bfe76b9ffa6fa64c47d8bfa0c78" title="real number">Real</a> notional = portfolioValue/putValue;</div>
<div class="line">            <span class="comment">// ...and we subtract from the portfolio a put with such</span></div>
<div class="line">            <span class="comment">// notional.</span></div>
<div class="line">            portfolio1.<a class="code" href="class_quant_lib_1_1_composite_instrument.html#a5d1575f5d5bd36deb2aafbeb785ceeb7" title="shorts an instrument from the composite">subtract</a>(putn, notional);</div>
<div class="line">        }</div>
<div class="line">        <span class="comment">// The portfolio being complete, we return to today&#39;s market...</span></div>
<div class="line">        <a class="code" href="class_quant_lib_1_1_singleton.html#ab7455b7e1235d292c444095842349291" title="access to the unique instance">Settings::instance</a>().evaluationDate() = today;</div>
<div class="line">        underlying-&gt;setValue(underlyingValue);</div>
<div class="line">        <span class="comment">// ...and output the value.</span></div>
<div class="line">        <a class="code" href="group__types.html#ga4bdf4bfe76b9ffa6fa64c47d8bfa0c78" title="real number">Real</a> portfolioValue = portfolio1.<a class="code" href="class_quant_lib_1_1_instrument.html#a4f791921f063f3ea19bd6efa9ceb4892" title="returns the net present value of the instrument.">NPV</a>();</div>
<div class="line">        <a class="code" href="group__types.html#ga4bdf4bfe76b9ffa6fa64c47d8bfa0c78" title="real number">Real</a> error = portfolioValue - referenceValue;</div>
<div class="line">        std::cout &lt;&lt; std::setw(widths[0]) &lt;&lt; std::left</div>
<div class="line">                  &lt;&lt; <span class="stringliteral">&quot;Replicating portfolio (12 dates)&quot;</span></div>
<div class="line">                  &lt;&lt; std::fixed</div>
<div class="line">                  &lt;&lt; std::setw(widths[1]) &lt;&lt; std::left &lt;&lt; portfolioValue</div>
<div class="line">                  &lt;&lt; std::setw(widths[2]) &lt;&lt; std::left &lt;&lt; error</div>
<div class="line">                  &lt;&lt; std::endl;</div>
<div class="line"> </div>
<div class="line">        <span class="comment">// For the second portfolio, we&#39;ll use 26 dates at two-weeks&#39;</span></div>
<div class="line">        <span class="comment">// distance.</span></div>
<div class="line">        <span class="keywordflow">for</span> (i=52; i&gt;=2; i-=2) {</div>
<div class="line">            <span class="comment">// Same as above.</span></div>
<div class="line">            <a class="code" href="class_quant_lib_1_1_date.html" title="Concrete date class.">Date</a> innerMaturity = today + i*Weeks;</div>
<div class="line">            ext::shared_ptr&lt;Exercise&gt; innerExercise(</div>
<div class="line">                                         <span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_european_exercise.html" title="European exercise.">EuropeanExercise</a>(innerMaturity));</div>
<div class="line">            ext::shared_ptr&lt;StrikedTypePayoff&gt; innerPayoff(</div>
<div class="line">                                <span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_plain_vanilla_payoff.html" title="Plain-vanilla payoff.">PlainVanillaPayoff</a>(Option::Put, barrier));</div>
<div class="line">            ext::shared_ptr&lt;Instrument&gt; putn(</div>
<div class="line">                              <span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_european_option.html" title="European option on a single asset.">EuropeanOption</a>(innerPayoff, innerExercise));</div>
<div class="line">            putn-&gt;setPricingEngine(europeanEngine);</div>
<div class="line">            <a class="code" href="class_quant_lib_1_1_date.html" title="Concrete date class.">Date</a> killDate = today + (i-2)*Weeks;</div>
<div class="line">            <a class="code" href="class_quant_lib_1_1_singleton.html#ab7455b7e1235d292c444095842349291" title="access to the unique instance">Settings::instance</a>().evaluationDate() = killDate;</div>
<div class="line">            underlying-&gt;setValue(barrier);</div>
<div class="line">            <a class="code" href="group__types.html#ga4bdf4bfe76b9ffa6fa64c47d8bfa0c78" title="real number">Real</a> portfolioValue = portfolio2.<a class="code" href="class_quant_lib_1_1_instrument.html#a4f791921f063f3ea19bd6efa9ceb4892" title="returns the net present value of the instrument.">NPV</a>();</div>
<div class="line">            <a class="code" href="group__types.html#ga4bdf4bfe76b9ffa6fa64c47d8bfa0c78" title="real number">Real</a> putValue = putn-&gt;NPV();</div>
<div class="line">            <a class="code" href="group__types.html#ga4bdf4bfe76b9ffa6fa64c47d8bfa0c78" title="real number">Real</a> notional = portfolioValue/putValue;</div>
<div class="line">            portfolio2.<a class="code" href="class_quant_lib_1_1_composite_instrument.html#a5d1575f5d5bd36deb2aafbeb785ceeb7" title="shorts an instrument from the composite">subtract</a>(putn, notional);</div>
<div class="line">        }</div>
<div class="line">        <a class="code" href="class_quant_lib_1_1_singleton.html#ab7455b7e1235d292c444095842349291" title="access to the unique instance">Settings::instance</a>().evaluationDate() = today;</div>
<div class="line">        underlying-&gt;setValue(underlyingValue);</div>
<div class="line">        portfolioValue = portfolio2.<a class="code" href="class_quant_lib_1_1_instrument.html#a4f791921f063f3ea19bd6efa9ceb4892" title="returns the net present value of the instrument.">NPV</a>();</div>
<div class="line">        error = portfolioValue - referenceValue;</div>
<div class="line">        std::cout &lt;&lt; std::setw(widths[0]) &lt;&lt; std::left</div>
<div class="line">                  &lt;&lt; <span class="stringliteral">&quot;Replicating portfolio (26 dates)&quot;</span></div>
<div class="line">                  &lt;&lt; std::fixed</div>
<div class="line">                  &lt;&lt; std::setw(widths[1]) &lt;&lt; std::left &lt;&lt; portfolioValue</div>
<div class="line">                  &lt;&lt; std::setw(widths[2]) &lt;&lt; std::left &lt;&lt; error</div>
<div class="line">                  &lt;&lt; std::endl;</div>
<div class="line"> </div>
<div class="line">        <span class="comment">// For the third portfolio, we&#39;ll use 52 dates at one-week&#39;s</span></div>
<div class="line">        <span class="comment">// distance.</span></div>
<div class="line">        <span class="keywordflow">for</span> (i=52; i&gt;=1; i--) {</div>
<div class="line">            <span class="comment">// Same as above.</span></div>
<div class="line">            <a class="code" href="class_quant_lib_1_1_date.html" title="Concrete date class.">Date</a> innerMaturity = today + i*Weeks;</div>
<div class="line">            ext::shared_ptr&lt;Exercise&gt; innerExercise(</div>
<div class="line">                                         <span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_european_exercise.html" title="European exercise.">EuropeanExercise</a>(innerMaturity));</div>
<div class="line">            ext::shared_ptr&lt;StrikedTypePayoff&gt; innerPayoff(</div>
<div class="line">                                <span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_plain_vanilla_payoff.html" title="Plain-vanilla payoff.">PlainVanillaPayoff</a>(Option::Put, barrier));</div>
<div class="line">            ext::shared_ptr&lt;Instrument&gt; putn(</div>
<div class="line">                              <span class="keyword">new</span> <a class="code" href="class_quant_lib_1_1_european_option.html" title="European option on a single asset.">EuropeanOption</a>(innerPayoff, innerExercise));</div>
<div class="line">            putn-&gt;setPricingEngine(europeanEngine);</div>
<div class="line">            <a class="code" href="class_quant_lib_1_1_date.html" title="Concrete date class.">Date</a> killDate = today + (i-1)*Weeks;</div>
<div class="line">            <a class="code" href="class_quant_lib_1_1_singleton.html#ab7455b7e1235d292c444095842349291" title="access to the unique instance">Settings::instance</a>().evaluationDate() = killDate;</div>
<div class="line">            underlying-&gt;setValue(barrier);</div>
<div class="line">            <a class="code" href="group__types.html#ga4bdf4bfe76b9ffa6fa64c47d8bfa0c78" title="real number">Real</a> portfolioValue = portfolio3.<a class="code" href="class_quant_lib_1_1_instrument.html#a4f791921f063f3ea19bd6efa9ceb4892" title="returns the net present value of the instrument.">NPV</a>();</div>
<div class="line">            <a class="code" href="group__types.html#ga4bdf4bfe76b9ffa6fa64c47d8bfa0c78" title="real number">Real</a> putValue = putn-&gt;NPV();</div>
<div class="line">            <a class="code" href="group__types.html#ga4bdf4bfe76b9ffa6fa64c47d8bfa0c78" title="real number">Real</a> notional = portfolioValue/putValue;</div>
<div class="line">            portfolio3.<a class="code" href="class_quant_lib_1_1_composite_instrument.html#a5d1575f5d5bd36deb2aafbeb785ceeb7" title="shorts an instrument from the composite">subtract</a>(putn, notional);</div>
<div class="line">        }</div>
<div class="line">        <a class="code" href="class_quant_lib_1_1_singleton.html#ab7455b7e1235d292c444095842349291" title="access to the unique instance">Settings::instance</a>().evaluationDate() = today;</div>
<div class="line">        underlying-&gt;setValue(underlyingValue);</div>
<div class="line">        portfolioValue = portfolio3.<a class="code" href="class_quant_lib_1_1_instrument.html#a4f791921f063f3ea19bd6efa9ceb4892" title="returns the net present value of the instrument.">NPV</a>();</div>
<div class="line">        error = portfolioValue - referenceValue;</div>
<div class="line">        std::cout &lt;&lt; std::setw(widths[0]) &lt;&lt; std::left</div>
<div class="line">                  &lt;&lt; <span class="stringliteral">&quot;Replicating portfolio (52 dates)&quot;</span></div>
<div class="line">                  &lt;&lt; std::fixed</div>
<div class="line">                  &lt;&lt; std::setw(widths[1]) &lt;&lt; std::left &lt;&lt; portfolioValue</div>
<div class="line">                  &lt;&lt; std::setw(widths[2]) &lt;&lt; std::left &lt;&lt; error</div>
<div class="line">                  &lt;&lt; std::endl;</div>
<div class="line"> </div>
<div class="line">        <span class="comment">// Now we modify the market condition to see whether the</span></div>
<div class="line">        <span class="comment">// replication holds. First, we change the underlying value so</span></div>
<div class="line">        <span class="comment">// that the option is out of the money.</span></div>
<div class="line">        std::cout &lt;&lt; dblrule &lt;&lt; std::endl;</div>
<div class="line">        std::cout &lt;&lt; <span class="stringliteral">&quot;Modified market conditions: out of the money&quot;</span></div>
<div class="line">                  &lt;&lt; std::endl;</div>
<div class="line">        std::cout &lt;&lt; dblrule &lt;&lt; std::endl;</div>
<div class="line">        std::cout &lt;&lt; std::setw(widths[0]) &lt;&lt; std::left &lt;&lt; <span class="stringliteral">&quot;Option&quot;</span></div>
<div class="line">                  &lt;&lt; std::setw(widths[1]) &lt;&lt; std::left &lt;&lt; <span class="stringliteral">&quot;NPV&quot;</span></div>
<div class="line">                  &lt;&lt; std::setw(widths[2]) &lt;&lt; std::left &lt;&lt; <span class="stringliteral">&quot;Error&quot;</span></div>
<div class="line">                  &lt;&lt; std::endl;</div>
<div class="line">        std::cout &lt;&lt; rule &lt;&lt; std::endl;</div>
<div class="line"> </div>
<div class="line">        underlying-&gt;setValue(110.0);</div>
<div class="line"> </div>
<div class="line">        referenceValue = referenceOption.NPV();</div>
<div class="line">        std::cout &lt;&lt; std::setw(widths[0]) &lt;&lt; std::left</div>
<div class="line">                  &lt;&lt; <span class="stringliteral">&quot;Original barrier option&quot;</span></div>
<div class="line">                  &lt;&lt; std::fixed</div>
<div class="line">                  &lt;&lt; std::setw(widths[1]) &lt;&lt; std::left &lt;&lt; referenceValue</div>
<div class="line">                  &lt;&lt; std::setw(widths[2]) &lt;&lt; std::left &lt;&lt; <span class="stringliteral">&quot;N/A&quot;</span></div>
<div class="line">                  &lt;&lt; std::endl;</div>
<div class="line">        portfolioValue = portfolio1.<a class="code" href="class_quant_lib_1_1_instrument.html#a4f791921f063f3ea19bd6efa9ceb4892" title="returns the net present value of the instrument.">NPV</a>();</div>
<div class="line">        error = portfolioValue - referenceValue;</div>
<div class="line">        std::cout &lt;&lt; std::setw(widths[0]) &lt;&lt; std::left</div>
<div class="line">                  &lt;&lt; <span class="stringliteral">&quot;Replicating portfolio (12 dates)&quot;</span></div>
<div class="line">                  &lt;&lt; std::fixed</div>
<div class="line">                  &lt;&lt; std::setw(widths[1]) &lt;&lt; std::left &lt;&lt; portfolioValue</div>
<div class="line">                  &lt;&lt; std::setw(widths[2]) &lt;&lt; std::left &lt;&lt; error</div>
<div class="line">                  &lt;&lt; std::endl;</div>
<div class="line">        portfolioValue = portfolio2.<a class="code" href="class_quant_lib_1_1_instrument.html#a4f791921f063f3ea19bd6efa9ceb4892" title="returns the net present value of the instrument.">NPV</a>();</div>
<div class="line">        error = portfolioValue - referenceValue;</div>
<div class="line">        std::cout &lt;&lt; std::setw(widths[0]) &lt;&lt; std::left</div>
<div class="line">                  &lt;&lt; <span class="stringliteral">&quot;Replicating portfolio (26 dates)&quot;</span></div>
<div class="line">                  &lt;&lt; std::fixed</div>
<div class="line">                  &lt;&lt; std::setw(widths[1]) &lt;&lt; std::left &lt;&lt; portfolioValue</div>
<div class="line">                  &lt;&lt; std::setw(widths[2]) &lt;&lt; std::left &lt;&lt; error</div>
<div class="line">                  &lt;&lt; std::endl;</div>
<div class="line">        portfolioValue = portfolio3.<a class="code" href="class_quant_lib_1_1_instrument.html#a4f791921f063f3ea19bd6efa9ceb4892" title="returns the net present value of the instrument.">NPV</a>();</div>
<div class="line">        error = portfolioValue - referenceValue;</div>
<div class="line">        std::cout &lt;&lt; std::setw(widths[0]) &lt;&lt; std::left</div>
<div class="line">                  &lt;&lt; <span class="stringliteral">&quot;Replicating portfolio (52 dates)&quot;</span></div>
<div class="line">                  &lt;&lt; std::fixed</div>
<div class="line">                  &lt;&lt; std::setw(widths[1]) &lt;&lt; std::left &lt;&lt; portfolioValue</div>
<div class="line">                  &lt;&lt; std::setw(widths[2]) &lt;&lt; std::left &lt;&lt; error</div>
<div class="line">                  &lt;&lt; std::endl;</div>
<div class="line"> </div>
<div class="line">        <span class="comment">// Next, we change the underlying value so that the option is</span></div>
<div class="line">        <span class="comment">// in the money.</span></div>
<div class="line">        std::cout &lt;&lt; dblrule &lt;&lt; std::endl;</div>
<div class="line">        std::cout &lt;&lt; <span class="stringliteral">&quot;Modified market conditions: in the money&quot;</span> &lt;&lt; std::endl;</div>
<div class="line">        std::cout &lt;&lt; dblrule &lt;&lt; std::endl;</div>
<div class="line">        std::cout &lt;&lt; std::setw(widths[0]) &lt;&lt; std::left &lt;&lt; <span class="stringliteral">&quot;Option&quot;</span></div>
<div class="line">                  &lt;&lt; std::setw(widths[1]) &lt;&lt; std::left &lt;&lt; <span class="stringliteral">&quot;NPV&quot;</span></div>
<div class="line">                  &lt;&lt; std::setw(widths[2]) &lt;&lt; std::left &lt;&lt; <span class="stringliteral">&quot;Error&quot;</span></div>
<div class="line">                  &lt;&lt; std::endl;</div>
<div class="line">        std::cout &lt;&lt; rule &lt;&lt; std::endl;</div>
<div class="line"> </div>
<div class="line">        underlying-&gt;setValue(90.0);</div>
<div class="line"> </div>
<div class="line">        referenceValue = referenceOption.NPV();</div>
<div class="line">        std::cout &lt;&lt; std::setw(widths[0]) &lt;&lt; std::left</div>
<div class="line">                  &lt;&lt; <span class="stringliteral">&quot;Original barrier option&quot;</span></div>
<div class="line">                  &lt;&lt; std::fixed</div>
<div class="line">                  &lt;&lt; std::setw(widths[1]) &lt;&lt; std::left &lt;&lt; referenceValue</div>
<div class="line">                  &lt;&lt; std::setw(widths[2]) &lt;&lt; std::left &lt;&lt; <span class="stringliteral">&quot;N/A&quot;</span></div>
<div class="line">                  &lt;&lt; std::endl;</div>
<div class="line">        portfolioValue = portfolio1.<a class="code" href="class_quant_lib_1_1_instrument.html#a4f791921f063f3ea19bd6efa9ceb4892" title="returns the net present value of the instrument.">NPV</a>();</div>
<div class="line">        error = portfolioValue - referenceValue;</div>
<div class="line">        std::cout &lt;&lt; std::setw(widths[0]) &lt;&lt; std::left</div>
<div class="line">                  &lt;&lt; <span class="stringliteral">&quot;Replicating portfolio (12 dates)&quot;</span></div>
<div class="line">                  &lt;&lt; std::fixed</div>
<div class="line">                  &lt;&lt; std::setw(widths[1]) &lt;&lt; std::left &lt;&lt; portfolioValue</div>
<div class="line">                  &lt;&lt; std::setw(widths[2]) &lt;&lt; std::left &lt;&lt; error</div>
<div class="line">                  &lt;&lt; std::endl;</div>
<div class="line">        portfolioValue = portfolio2.<a class="code" href="class_quant_lib_1_1_instrument.html#a4f791921f063f3ea19bd6efa9ceb4892" title="returns the net present value of the instrument.">NPV</a>();</div>
<div class="line">        error = portfolioValue - referenceValue;</div>
<div class="line">        std::cout &lt;&lt; std::setw(widths[0]) &lt;&lt; std::left</div>
<div class="line">                  &lt;&lt; <span class="stringliteral">&quot;Replicating portfolio (26 dates)&quot;</span></div>
<div class="line">                  &lt;&lt; std::fixed</div>
<div class="line">                  &lt;&lt; std::setw(widths[1]) &lt;&lt; std::left &lt;&lt; portfolioValue</div>
<div class="line">                  &lt;&lt; std::setw(widths[2]) &lt;&lt; std::left &lt;&lt; error</div>
<div class="line">                  &lt;&lt; std::endl;</div>
<div class="line">        portfolioValue = portfolio3.<a class="code" href="class_quant_lib_1_1_instrument.html#a4f791921f063f3ea19bd6efa9ceb4892" title="returns the net present value of the instrument.">NPV</a>();</div>
<div class="line">        error = portfolioValue - referenceValue;</div>
<div class="line">        std::cout &lt;&lt; std::setw(widths[0]) &lt;&lt; std::left</div>
<div class="line">                  &lt;&lt; <span class="stringliteral">&quot;Replicating portfolio (52 dates)&quot;</span></div>
<div class="line">                  &lt;&lt; std::fixed</div>
<div class="line">                  &lt;&lt; std::setw(widths[1]) &lt;&lt; std::left &lt;&lt; portfolioValue</div>
<div class="line">                  &lt;&lt; std::setw(widths[2]) &lt;&lt; std::left &lt;&lt; error</div>
<div class="line">                  &lt;&lt; std::endl;</div>
<div class="line"> </div>
<div class="line">        <span class="comment">// Finally, a word of warning for those (shame on them) who</span></div>
<div class="line">        <span class="comment">// run the example but do not read the code.</span></div>
<div class="line">        std::cout &lt;&lt; dblrule &lt;&lt; std::endl;</div>
<div class="line">        std::cout</div>
<div class="line">            &lt;&lt; std::endl</div>
<div class="line">            &lt;&lt; <span class="stringliteral">&quot;The replication seems to be less robust when volatility and \n&quot;</span></div>
<div class="line">            &lt;&lt; <span class="stringliteral">&quot;risk-free rate are changed. Feel free to experiment with \n&quot;</span></div>
<div class="line">            &lt;&lt; <span class="stringliteral">&quot;the example and contribute a patch if you spot any errors.&quot;</span></div>
<div class="line">            &lt;&lt; std::endl;</div>
<div class="line"> </div>
<div class="line">        <span class="keywordflow">return</span> 0;</div>
<div class="line">    } <span class="keywordflow">catch</span> (std::exception&amp; e) {</div>
<div class="line">        std::cerr &lt;&lt; e.what() &lt;&lt; std::endl;</div>
<div class="line">        <span class="keywordflow">return</span> 1;</div>
<div class="line">    } <span class="keywordflow">catch</span> (...) {</div>
<div class="line">        std::cerr &lt;&lt; <span class="stringliteral">&quot;unknown error&quot;</span> &lt;&lt; std::endl;</div>
<div class="line">        <span class="keywordflow">return</span> 1;</div>
<div class="line">    }</div>
<div class="line">}</div>
</div><!-- fragment --> </div><!-- contents -->
<!-- HTML footer for doxygen 1.8.9.1-->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by <a href="http://www.doxygen.org/index.html">Doxygen</a>
1.8.20
</small></address>
</body>
</html>