Skip to content

Commit

Permalink
Add std::ostream for Compounding enum (#2007)
Browse files Browse the repository at this point in the history
  • Loading branch information
lballabio authored Jul 2, 2024
2 parents 2c3f675 + df45b7a commit a1a7cc8
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion ql/compounding.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#ifndef quantlib_compounding_hpp
#define quantlib_compounding_hpp

#include <ql/qldefines.hpp>
#include <ql/errors.hpp>

namespace QuantLib {

Expand All @@ -36,6 +36,22 @@ namespace QuantLib {
CompoundedThenSimple //!< Compounded up to the first period then Simple
};

inline std::ostream& operator<<(std::ostream& out, const Compounding& compounding) {
switch (compounding) {
case Compounding::Simple:
return out << "Simple";
case Compounding::Compounded:
return out << "Compounded";
case Compounding::Continuous:
return out << "Continuous";
case Compounding::SimpleThenCompounded:
return out << "SimpleThenCompounded";
case Compounding::CompoundedThenSimple:
return out << "CompoundedThenSimple";
default:
QL_FAIL("unknown compounding type");
}
}
}

#endif

0 comments on commit a1a7cc8

Please sign in to comment.