Skip to content

Commit

Permalink
use std::transform + style change
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulXiCao committed Dec 2, 2023
1 parent 9e190c0 commit b0af6f1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions ql/prices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
FOR A PARTICULAR PURPOSE. See the license for more details.
*/

#include <algorithm>
#include <ql/prices.hpp>
#include <ql/errors.hpp>

Expand Down Expand Up @@ -134,9 +135,10 @@ namespace QuantLib {
IntervalPrice::Type t) {
std::vector<Real> returnval;
returnval.reserve(ts.size());
for (const auto& i : ts) {
returnval.push_back(i.second.value(t));
}
std::transform(ts.begin(), ts.end(), std::back_inserter(returnval),
[t](const std::pair<Date, IntervalPrice>& date_price) -> Real {
return date_price.second.value(t);
});
return returnval;
}

Expand Down
2 changes: 1 addition & 1 deletion ql/prices.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ namespace QuantLib {
IntervalPrice::Type);
static TimeSeries<Real> extractComponent(
const TimeSeries<IntervalPrice>&,
enum IntervalPrice::Type);
IntervalPrice::Type);
//@}
private:
Real open_, close_, high_, low_;
Expand Down

0 comments on commit b0af6f1

Please sign in to comment.