lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 66944d8 2/3: Use make_shared in the most obvi


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 66944d8 2/3: Use make_shared in the most obvious cases
Date: Sat, 6 Feb 2021 14:47:06 -0500 (EST)

branch: master
commit 66944d897233d5734bd75c6025b9ae1a1427a46b
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Use make_shared in the most obvious cases
    
    Here, "most obvious" means identified by:
      git grep '_ptr.*new'
---
 database.cpp         | 2 +-
 input_test.cpp       | 2 +-
 ledger.cpp           | 4 ++--
 premium_tax_test.cpp | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/database.cpp b/database.cpp
index 4a21079..8fc29a6 100644
--- a/database.cpp
+++ b/database.cpp
@@ -226,7 +226,7 @@ namespace
 
 std::shared_ptr<DBDictionary const> antediluvian_db()
 {
-    std::shared_ptr<DBDictionary> z(new DBDictionary);
+    auto z = std::make_shared<DBDictionary>();
     z->InitAntediluvian();
     LMI_ASSERT(z);
     return z;
diff --git a/input_test.cpp b/input_test.cpp
index 394631e..3487192 100644
--- a/input_test.cpp
+++ b/input_test.cpp
@@ -101,7 +101,7 @@ void input_test::test_product_database()
     Input input;
     yare_input yi(input);
     product_database db(yi);
-    std::shared_ptr<DBDictionary> x(new DBDictionary);
+    auto x = std::make_shared<DBDictionary>();
     db.db_ = x;
     DBDictionary& dictionary = *x;
     dictionary.Add({DB_ChildRiderMinAmt, 25000});
diff --git a/ledger.cpp b/ledger.cpp
index d14a6ac..83ceadc 100644
--- a/ledger.cpp
+++ b/ledger.cpp
@@ -43,8 +43,8 @@
 //   Ledger Ledger::Clone() const
 //   {
 //       Ledger new_ledger(*this);
-//       new_ledger.ledger_map_       = std::shared_ptr<ledger_map_holder>(new 
ledger_map_holder(*ledger_map_));
-//       new_ledger.ledger_invariant_ = std::shared_ptr<LedgerInvariant>(new 
LedgerInvariant(*ledger_invariant_));
+//       new_ledger.ledger_map_       = 
std::make_shared<ledger_map_holder>(*ledger_map_);
+//       new_ledger.ledger_invariant_ = 
std::make_shared_ptr<LedgerInvariant>(*ledger_invariant_);
 //       return new_ledger;
 //   }
 // that would make unshared copies? If not, then Clone() would be
diff --git a/premium_tax_test.cpp b/premium_tax_test.cpp
index 1f101bf..67c56d7 100644
--- a/premium_tax_test.cpp
+++ b/premium_tax_test.cpp
@@ -99,7 +99,7 @@ void premium_tax_test::test_rates()
     // A uniform but nonzero load would elicit a runtime error,
     // because the tiered load is not zero.
     {
-    std::shared_ptr<DBDictionary> x(new DBDictionary);
+    auto x = std::make_shared<DBDictionary>();
     db.db_ = x;
     DBDictionary& dictionary = *x;
 



reply via email to

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