lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master bc32401 5/6: Replace std::shared_ptr with std


From: Greg Chicares
Subject: [lmi-commits] [lmi] master bc32401 5/6: Replace std::shared_ptr with std::unique_ptr
Date: Fri, 19 Oct 2018 15:45:07 -0400 (EDT)

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

    Replace std::shared_ptr with std::unique_ptr
    
    This change brings no great benefit per se, though it does demonstrate
    the usefulness of the refactoring spread over the last several commits.
    Even better than replacing a heavy smart pointer with a light one will
    be to replace a smart pointer with the object it would hold: that's
    simpler, and gets rid of the problem that pointers can be null.
---
 group_values.cpp | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/group_values.cpp b/group_values.cpp
index 733b00f..b096902 100644
--- a/group_values.cpp
+++ b/group_values.cpp
@@ -43,8 +43,9 @@
 
 #include <algorithm>                    // max()
 #include <iterator>                     // back_inserter()
-#include <memory>                       // make_shared()
+#include <memory>                       // make_unique()
 #include <string>
+#include <utility>                      // move()
 
 namespace
 {
@@ -252,7 +253,7 @@ census_run_result run_census_in_parallel::operator()
 
     ledger_emitter emitter(file, emission);
 
-    std::vector<std::shared_ptr<AccountValue>> cell_values;
+    std::vector<std::unique_ptr<AccountValue>> cell_values;
     std::vector<mcenum_run_basis> const& RunBases = composite.GetRunBases();
 
     int const first_cell_inforce_year  = 
value_cast<int>((*cells.begin())["InforceYear"].str());
@@ -268,8 +269,8 @@ census_run_result run_census_in_parallel::operator()
             {
             { // Begin fenv_guard scope.
             fenv_guard fg;
-            auto z {std::make_shared<AccountValue>(ip)};
-            cell_values.push_back(z);
+            auto z {std::make_unique<AccountValue>(ip)};
+            cell_values.push_back(std::move(z));
             AccountValue& av = *cell_values.back();
 
             std::string const name(cells[j]["InsuredName"].str());



reply via email to

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