lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master b48b07f 1/2: static_cast directly from double


From: Greg Chicares
Subject: [lmi-commits] [lmi] master b48b07f 1/2: static_cast directly from double to enum
Date: Tue, 23 Oct 2018 10:44:26 -0400 (EDT)

branch: master
commit b48b07fde6d92ac1347f3e25300d92d72d125b62
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    static_cast directly from double to enum
    
    Removed multistep casts that are no longer necessary. C++17 (N4659)
    [8.2.9/10] says:
    
    | A value of floating-point type can also be explicitly converted to an
    | enumeration type. The resulting value is the same as converting the
    | original value to the underlying type of the enumeration (7.10), and
    | subsequently to the enumeration type.
---
 basicvalues.cpp           |  7 +------
 gpt_input.cpp             |  8 ++------
 ihs_acctval.cpp           | 16 ++++++++--------
 ihs_basicval.cpp          | 30 ++++++++++--------------------
 input_harmonization.cpp   | 12 +++---------
 ledger_invariant_init.cpp |  2 +-
 mec_input.cpp             |  8 ++------
 7 files changed, 27 insertions(+), 56 deletions(-)

diff --git a/basicvalues.cpp b/basicvalues.cpp
index aa8b198..5373b05 100644
--- a/basicvalues.cpp
+++ b/basicvalues.cpp
@@ -104,12 +104,7 @@ void BasicValues::Init()
     EndtAge = static_cast<int>(Database_->Query(DB_MaturityAge));
     Length = EndtAge - IssueAge;
 
-    ledger_type_ =
-        static_cast<mcenum_ledger_type>
-            (static_cast<int>
-                (Database_->Query(DB_LedgerType))
-            )
-        ;
+    ledger_type_ = 
static_cast<mcenum_ledger_type>(Database_->Query(DB_LedgerType));
     nonillustrated_       = 
static_cast<bool>(Database_->Query(DB_Nonillustrated));
     bool no_longer_issued = 
static_cast<bool>(Database_->Query(DB_NoLongerIssued));
     bool is_new_business  = yare_input_.EffectiveDate == 
yare_input_.InforceAsOfDate;
diff --git a/gpt_input.cpp b/gpt_input.cpp
index 5e32ada..39c0ab1 100644
--- a/gpt_input.cpp
+++ b/gpt_input.cpp
@@ -404,9 +404,7 @@ void gpt_input::DoHarmonize()
 
     oenum_alb_or_anb const alb_anb =
         static_cast<oenum_alb_or_anb>
-            (static_cast<int>
-                (database_->Query(DB_AgeLastOrNearest)
-                )
+            (database_->Query(DB_AgeLastOrNearest)
             );
     DateOfBirth.minimum_and_maximum
         (minimum_birthdate(IssueAge.maximum(), EffectiveDate.value(), alb_anb)
@@ -550,9 +548,7 @@ void gpt_input::DoTransmogrify()
 
     oenum_alb_or_anb const alb_anb =
         static_cast<oenum_alb_or_anb>
-            (static_cast<int>
-                (database_->Query(DB_AgeLastOrNearest)
-                )
+            (database_->Query(DB_AgeLastOrNearest)
             );
 
     int apparent_age = attained_age
diff --git a/ihs_acctval.cpp b/ihs_acctval.cpp
index e23ad8f..1d9beeb 100644
--- a/ihs_acctval.cpp
+++ b/ihs_acctval.cpp
@@ -720,28 +720,28 @@ void AccountValue::SetInitialValues()
     Internal1035Amount = Outlay_->internal_1035_amount();
 
     ee_premium_allocation_method   = static_cast<oenum_allocation_method>
-        (static_cast<int>(Database_->Query(DB_EePremMethod))
+        (Database_->Query(DB_EePremMethod)
         );
     ee_premium_preferred_account   = 
static_cast<oenum_increment_account_preference>
-        (static_cast<int>(Database_->Query(DB_EePremAcct))
+        (Database_->Query(DB_EePremAcct)
         );
     er_premium_allocation_method   = static_cast<oenum_allocation_method>
-        (static_cast<int>(Database_->Query(DB_ErPremMethod))
+        (Database_->Query(DB_ErPremMethod)
         );
     er_premium_preferred_account   = 
static_cast<oenum_increment_account_preference>
-        (static_cast<int>(Database_->Query(DB_ErPremAcct))
+        (Database_->Query(DB_ErPremAcct)
         );
     deduction_method               = static_cast<oenum_increment_method>
-        (static_cast<int>(Database_->Query(DB_DeductionMethod))
+        (Database_->Query(DB_DeductionMethod)
         );
     deduction_preferred_account    = 
static_cast<oenum_increment_account_preference>
-        (static_cast<int>(Database_->Query(DB_DeductionAcct))
+        (Database_->Query(DB_DeductionAcct)
         );
     distribution_method            = static_cast<oenum_increment_method>
-        (static_cast<int>(Database_->Query(DB_DistributionMethod))
+        (Database_->Query(DB_DistributionMethod)
         );
     distribution_preferred_account = 
static_cast<oenum_increment_account_preference>
-        (static_cast<int>(Database_->Query(DB_DistributionAcct))
+        (Database_->Query(DB_DistributionAcct)
         );
 
     // If any account preference is the separate account, then a
diff --git a/ihs_basicval.cpp b/ihs_basicval.cpp
index 8bbc317..02ef4d6 100644
--- a/ihs_basicval.cpp
+++ b/ihs_basicval.cpp
@@ -170,12 +170,7 @@ void BasicValues::Init()
     EndtAge = static_cast<int>(Database_->Query(DB_MaturityAge));
     Length = EndtAge - IssueAge;
 
-    ledger_type_ =
-        static_cast<mcenum_ledger_type>
-            (static_cast<int>
-                (Database_->Query(DB_LedgerType))
-            )
-        ;
+    ledger_type_ = 
static_cast<mcenum_ledger_type>(Database_->Query(DB_LedgerType));
     nonillustrated_       = 
static_cast<bool>(Database_->Query(DB_Nonillustrated));
     bool no_longer_issued = 
static_cast<bool>(Database_->Query(DB_NoLongerIssued));
     bool is_new_business  = yare_input_.EffectiveDate == 
yare_input_.InforceAsOfDate;
@@ -276,12 +271,7 @@ void BasicValues::GPTServerInit()
     yare_input_.DeathBenefitOption        .assign(Length, 
yare_input_.DeathBenefitOption[0]);
     yare_input_.FlatExtra                 .resize(Length);
 
-    ledger_type_ =
-        static_cast<mcenum_ledger_type>
-            (static_cast<int>
-                (Database_->Query(DB_LedgerType))
-            )
-        ;
+    ledger_type_ = 
static_cast<mcenum_ledger_type>(Database_->Query(DB_LedgerType));
     nonillustrated_       = 
static_cast<bool>(Database_->Query(DB_Nonillustrated));
     bool no_longer_issued = 
static_cast<bool>(Database_->Query(DB_NoLongerIssued));
     bool is_new_business  = yare_input_.EffectiveDate == 
yare_input_.InforceAsOfDate;
@@ -634,8 +624,8 @@ void BasicValues::SetPermanentInvariants()
     TermForcedConvAge   = 
static_cast<int>(Database_->Query(DB_TermForcedConvAge));
     TermForcedConvDur   = 
static_cast<int>(Database_->Query(DB_TermForcedConvDur));
     ExpPerKLimit        = Database_->Query(DB_ExpSpecAmtLimit      );
-    MinPremType         = 
static_cast<oenum_modal_prem_type>(static_cast<int>(Database_->Query(DB_MinPremType)));
-    TgtPremType         = 
static_cast<oenum_modal_prem_type>(static_cast<int>(Database_->Query(DB_TgtPremType)));
+    MinPremType         = 
static_cast<oenum_modal_prem_type>(Database_->Query(DB_MinPremType));
+    TgtPremType         = 
static_cast<oenum_modal_prem_type>(Database_->Query(DB_TgtPremType));
     TgtPremFixedAtIssue = Database_->Query(DB_TgtPremFixedAtIssue  );
     TgtPremMonthlyPolFee= Database_->Query(DB_TgtPremMonthlyPolFee );
     // Assertion: see comments on GetModalPremTgtFromTable().
@@ -647,12 +637,12 @@ void BasicValues::SetPermanentInvariants()
     CurrCoiTable1Limit  = Database_->Query(DB_CurrCoiTable1Limit   );
     LMI_ASSERT(0.0                <= CurrCoiTable0Limit);
     LMI_ASSERT(CurrCoiTable0Limit <= CurrCoiTable1Limit);
-    CoiInforceReentry   = 
static_cast<e_actuarial_table_method>(static_cast<int>(Database_->Query(DB_CoiInforceReentry)));
-    MaxWDDed_           = 
static_cast<mcenum_anticipated_deduction>(static_cast<int>(Database_->Query(DB_MaxWdDed)));
+    CoiInforceReentry   = 
static_cast<e_actuarial_table_method>(Database_->Query(DB_CoiInforceReentry));
+    MaxWDDed_           = 
static_cast<mcenum_anticipated_deduction>(Database_->Query(DB_MaxWdDed));
     MaxWdGenAcctValMult = Database_->Query(DB_MaxWdGenAcctValMult  );
     MaxWdSepAcctValMult = Database_->Query(DB_MaxWdSepAcctValMult  );
     AllowPrefLoan       = 
static_cast<bool>(Database_->Query(DB_AllowPrefLoan));
-    MaxLoanDed_         = 
static_cast<mcenum_anticipated_deduction>(static_cast<int>(Database_->Query(DB_MaxLoanDed)));
+    MaxLoanDed_         = 
static_cast<mcenum_anticipated_deduction>(Database_->Query(DB_MaxLoanDed));
     MaxLoanAVMult       = Database_->Query(DB_MaxLoanAcctValMult   );
     FirstPrefLoanYear   = 
static_cast<int>(Database_->Query(DB_FirstPrefLoanYear));
     NoLapseMinDur       = static_cast<int>(Database_->Query(DB_NoLapseMinDur));
@@ -666,7 +656,7 @@ void BasicValues::SetPermanentInvariants()
     AllowChangeToDBO2   = Database_->Query(DB_AllowChangeToDbo2    );
     AllowSAIncr         = Database_->Query(DB_AllowSpecAmtIncr     );
     NoLapseAlwaysActive = Database_->Query(DB_NoLapseAlwaysActive  );
-    WaiverChargeMethod  = 
static_cast<oenum_waiver_charge_method>(static_cast<int>(Database_->Query(DB_WpChargeMethod)));
+    WaiverChargeMethod  = 
static_cast<oenum_waiver_charge_method>(Database_->Query(DB_WpChargeMethod));
     LapseIgnoresSurrChg = Database_->Query(DB_LapseIgnoresSurrChg  );
     SurrChgOnIncr       = Database_->Query(DB_SurrChgOnIncr        );
     SurrChgOnDecr       = Database_->Query(DB_SurrChgOnDecr        );
@@ -766,10 +756,10 @@ void BasicValues::SetPermanentInvariants()
     // definitions, and 'DefinitionOfMaterialChange' will be removed.
     if(!global_settings::instance().ash_nazg())
         {
-        mcenum_defn_material_change const z = 
static_cast<mcenum_defn_material_change>(static_cast<int>(Database_->Query(DB_CvatMatChangeDefn)));
+        mcenum_defn_material_change const z = 
static_cast<mcenum_defn_material_change>(Database_->Query(DB_CvatMatChangeDefn));
         DefnMaterialChange_ = (mce_gpt == DefnLifeIns_) ? mce_adjustment_event 
: z;
         }
-    Equiv7702DBO3       = 
static_cast<mcenum_dbopt_7702>(static_cast<int>(Database_->Query(DB_Equiv7702Dbo3)));
+    Equiv7702DBO3       = 
static_cast<mcenum_dbopt_7702>(Database_->Query(DB_Equiv7702Dbo3));
     TermIsDbFor7702     = 1.0 == Database_->Query(DB_TermIsQABOrDb7702 );
     TermIsDbFor7702A    = 1.0 == Database_->Query(DB_TermIsQABOrDb7702A);
     MaxNAAR             = yare_input_.MaximumNaar;
diff --git a/input_harmonization.cpp b/input_harmonization.cpp
index a649edb..0260826 100644
--- a/input_harmonization.cpp
+++ b/input_harmonization.cpp
@@ -97,9 +97,7 @@ void Input::DoAdaptExternalities()
 
     GleanedLedgerType_ =
         static_cast<mcenum_ledger_type>
-            (static_cast<int>
-                (database_->Query(DB_LedgerType)
-                )
+            (database_->Query(DB_LedgerType)
             );
 }
 
@@ -278,9 +276,7 @@ void Input::DoHarmonize()
 
     oenum_alb_or_anb const alb_anb =
         static_cast<oenum_alb_or_anb>
-            (static_cast<int>
-                (database_->Query(DB_AgeLastOrNearest)
-                )
+            (database_->Query(DB_AgeLastOrNearest)
             );
     DateOfBirth.minimum_and_maximum
         (minimum_birthdate(IssueAge.maximum(), EffectiveDate.value(), alb_anb)
@@ -920,9 +916,7 @@ void Input::DoTransmogrify()
 
     oenum_alb_or_anb const alb_anb =
         static_cast<oenum_alb_or_anb>
-            (static_cast<int>
-                (database_->Query(DB_AgeLastOrNearest)
-                )
+            (database_->Query(DB_AgeLastOrNearest)
             );
 
     int apparent_age = attained_age
diff --git a/ledger_invariant_init.cpp b/ledger_invariant_init.cpp
index d8d0133..d20ba6a 100644
--- a/ledger_invariant_init.cpp
+++ b/ledger_invariant_init.cpp
@@ -441,7 +441,7 @@ void LedgerInvariant::Init(BasicValues const* b)
     //
     oenum_smoking_or_tobacco smoke_or_tobacco =
         static_cast<oenum_smoking_or_tobacco>
-            (static_cast<int>(b->Database_->Query(DB_SmokeOrTobacco))
+            (b->Database_->Query(DB_SmokeOrTobacco)
             );
     if(oe_tobacco_nontobacco == smoke_or_tobacco)
         {
diff --git a/mec_input.cpp b/mec_input.cpp
index e1f08b6..6c54b49 100644
--- a/mec_input.cpp
+++ b/mec_input.cpp
@@ -371,9 +371,7 @@ void mec_input::DoHarmonize()
 
     oenum_alb_or_anb const alb_anb =
         static_cast<oenum_alb_or_anb>
-            (static_cast<int>
-                (database_->Query(DB_AgeLastOrNearest)
-                )
+            (database_->Query(DB_AgeLastOrNearest)
             );
     DateOfBirth.minimum_and_maximum
         (minimum_birthdate(IssueAge.maximum(), EffectiveDate.value(), alb_anb)
@@ -497,9 +495,7 @@ void mec_input::DoTransmogrify()
 
     oenum_alb_or_anb const alb_anb =
         static_cast<oenum_alb_or_anb>
-            (static_cast<int>
-                (database_->Query(DB_AgeLastOrNearest)
-                )
+            (database_->Query(DB_AgeLastOrNearest)
             );
 
     int apparent_age = attained_age



reply via email to

[Prev in Thread] Current Thread [Next in Thread]