Coverage Report

Created: 2026-03-11 06:44

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/quantlib/ql/cashflows/dividend.cpp
Line
Count
Source
1
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3
/*
4
 Copyright (C) 2005 Joseph Wang
5
 Copyright (C) 2006 StatPro Italia srl
6
7
 This file is part of QuantLib, a free-software/open-source library
8
 for financial quantitative analysts and developers - http://quantlib.org/
9
10
 QuantLib is free software: you can redistribute it and/or modify it
11
 under the terms of the QuantLib license.  You should have received a
12
 copy of the license along with this program; if not, please email
13
 <quantlib-dev@lists.sf.net>. The license is also available online at
14
 <https://www.quantlib.org/license.shtml>.
15
16
 This program is distributed in the hope that it will be useful, but WITHOUT
17
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18
 FOR A PARTICULAR PURPOSE.  See the license for more details.
19
*/
20
21
#include <ql/cashflows/dividend.hpp>
22
#include <ql/patterns/visitor.hpp>
23
24
namespace QuantLib {
25
26
0
    void Dividend::accept(AcyclicVisitor& v) {
27
0
        auto* v1 = dynamic_cast<Visitor<Dividend>*>(&v);
28
0
        if (v1 != nullptr)
29
0
            v1->visit(*this);
30
0
        else
31
0
            CashFlow::accept(v);
32
0
    }
33
34
    std::vector<ext::shared_ptr<Dividend> >
35
    DividendVector(const std::vector<Date>& dividendDates,
36
0
                   const std::vector<Real>& dividends) {
37
38
0
        QL_REQUIRE(dividendDates.size() == dividends.size(),
39
0
                   "size mismatch between dividend dates and amounts");
40
41
0
        std::vector<Date>::const_iterator dd;
42
0
        std::vector<Real>::const_iterator d;
43
0
        std::vector<ext::shared_ptr<Dividend> > items;
44
0
        items.reserve(dividendDates.size());
45
0
        for (dd = dividendDates.begin(), d = dividends.begin();
46
0
             dd != dividendDates.end(); ++dd, ++d) {
47
0
            items.push_back(ext::shared_ptr<Dividend>(new
48
0
                FixedDividend(*d, *dd)));
49
0
        }
50
0
        return items;
51
0
    }
52
53
}
54