[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master a1d772b 03/15: Prefer 'switch' to if...else_i
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master a1d772b 03/15: Prefer 'switch' to if...else_if...else |
Date: |
Tue, 27 Aug 2019 13:50:18 -0400 (EDT) |
branch: master
commit a1d772b7d4b5386c31d1a581e6bc71024ed97a54
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Prefer 'switch' to if...else_if...else
---
ihs_basicval.cpp | 60 +++++++++++++++++++-------------------------------------
1 file changed, 20 insertions(+), 40 deletions(-)
diff --git a/ihs_basicval.cpp b/ihs_basicval.cpp
index 4e7d683..c57aeca 100644
--- a/ihs_basicval.cpp
+++ b/ihs_basicval.cpp
@@ -869,26 +869,16 @@ double BasicValues::GetModalPrem
,oenum_modal_prem_type a_prem_type
) const
{
- if(oe_monthly_deduction == a_prem_type)
+ switch(a_prem_type)
{
- return GetModalPremMlyDed (a_year, a_mode, a_specamt);
+ case oe_monthly_deduction:
+ return GetModalPremMlyDed (a_year, a_mode, a_specamt);
+ case oe_modal_nonmec:
+ return GetModalPremMaxNonMec (a_year, a_mode, a_specamt);
+ case oe_modal_table:
+ return GetModalPremTgtFromTable(a_year, a_mode, a_specamt);
}
- else if(oe_modal_nonmec == a_prem_type)
- {
- return GetModalPremMaxNonMec (a_year, a_mode, a_specamt);
- }
- else if(oe_modal_table == a_prem_type)
- {
- return GetModalPremTgtFromTable(a_year, a_mode, a_specamt);
- }
- else
- {
- alarum()
- << "Unknown modal premium type " << a_prem_type << '.'
- << LMI_FLUSH
- ;
- }
- return 0.0;
+ throw "Unreachable--silences a compiler diagnostic.";
}
/// Calculate premium using a seven-pay ratio.
@@ -1408,30 +1398,20 @@ double BasicValues::GetModalSpecAmt
,oenum_modal_prem_type premium_type
) const
{
- if(oe_monthly_deduction == premium_type)
- {
- return GetModalSpecAmtMlyDed(annualized_pmt, mce_annual);
- }
- else if(oe_modal_nonmec == premium_type)
+ switch(premium_type)
{
- return GetModalSpecAmtMinNonMec(annualized_pmt);
- }
- else if(oe_modal_table == premium_type)
- {
- return round_min_specamt()
- (
- (annualized_pmt - TgtPremMonthlyPolFee * 12)
- / MortalityRates_->TargetPremiumRates()[0]
- );
- }
- else
- {
- alarum()
- << "Unknown modal premium type " << premium_type << '.'
- << LMI_FLUSH
- ;
+ case oe_monthly_deduction:
+ return GetModalSpecAmtMlyDed(annualized_pmt, mce_annual);
+ case oe_modal_nonmec:
+ return GetModalSpecAmtMinNonMec(annualized_pmt);
+ case oe_modal_table:
+ return round_min_specamt()
+ (
+ (annualized_pmt - TgtPremMonthlyPolFee * 12)
+ / MortalityRates_->TargetPremiumRates()[0]
+ );
}
- return 0.0;
+ throw "Unreachable--silences a compiler diagnostic.";
}
/// Calculate specified amount using a seven-pay ratio.
- [lmi-commits] [lmi] master updated (e0bf6c4 -> 80e47f2), Greg Chicares, 2019/08/27
- [lmi-commits] [lmi] master fee9d55 02/15: Support tabular minimum premiums, Greg Chicares, 2019/08/27
- [lmi-commits] [lmi] master a1d772b 03/15: Prefer 'switch' to if...else_if...else,
Greg Chicares <=
- [lmi-commits] [lmi] master 3d6e389 07/15: Simplify single-premium logic, Greg Chicares, 2019/08/27
- [lmi-commits] [lmi] master a74799d 06/15: Add a 'GuarCoiWhence' database entity, Greg Chicares, 2019/08/27
- [lmi-commits] [lmi] master e010c8f 04/15: Distinguish tabular minimum and target premiums, Greg Chicares, 2019/08/27
- [lmi-commits] [lmi] master 3e7a753 05/15: Resolve and document the policy-fee issue noted in the last commit, Greg Chicares, 2019/08/27
- [lmi-commits] [lmi] master 6b1abc0 11/15: Rework {flexible, single}-premium footnotes, Greg Chicares, 2019/08/27
- [lmi-commits] [lmi] master b2e4af3 08/15: Make 'IsSinglePremium' enumerative, Greg Chicares, 2019/08/27
- [lmi-commits] [lmi] master 6596a29 12/15: Reformat to highlight similarity, Greg Chicares, 2019/08/27
- [lmi-commits] [lmi] master 80e47f2 15/15: Substitute product-database strings for literal text, Greg Chicares, 2019/08/27
- [lmi-commits] [lmi] master 2994f27 13/15: Simplify and condense, Greg Chicares, 2019/08/27
- [lmi-commits] [lmi] master 04f9369 01/15: Add <MinPremFilename>, Greg Chicares, 2019/08/27