[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());
- [lmi-commits] [lmi] master updated (4c21bf7 -> 2ba6003), Greg Chicares, 2018/10/19
- [lmi-commits] [lmi] master 8eead43 4/6: Don't write 'new', Greg Chicares, 2018/10/19
- [lmi-commits] [lmi] master 4d87259 3/6: Create and use a proper alias, Greg Chicares, 2018/10/19
- [lmi-commits] [lmi] master d2b8c01 1/6: Improve physical design: unique_ptr member --> out-of-line ~owner(), Greg Chicares, 2018/10/19
- [lmi-commits] [lmi] master bc32401 5/6: Replace std::shared_ptr with std::unique_ptr,
Greg Chicares <=
- [lmi-commits] [lmi] master 86bf250 2/6: Reorder a statement, Greg Chicares, 2018/10/19
- [lmi-commits] [lmi] master 2ba6003 6/6: Dispense with smart pointers, Greg Chicares, 2018/10/19