lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master de0060c 1/5: Last element is spelled "back()"


From: Greg Chicares
Subject: [lmi-commits] [lmi] master de0060c 1/5: Last element is spelled "back()"
Date: Wed, 25 Jan 2017 01:45:53 +0000 (UTC)

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

    Last element is spelled "back()"
---
 gpt_test.cpp          |    4 ++--
 input_sequence.cpp    |    4 ++--
 test_coding_rules.cpp |    3 ++-
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/gpt_test.cpp b/gpt_test.cpp
index 6b19c3d..44e7014 100644
--- a/gpt_test.cpp
+++ b/gpt_test.cpp
@@ -370,12 +370,12 @@ void gpt_test::test_invariants()
     initialize(0); // Reset.
 
     // Monthly q equal to unity: probably a bad idea, but permitted.
-    q_m[q_m.size() - 1] = 1.0;
+    q_m.back() = 1.0;
     instantiate_cf();
     initialize(0); // Reset.
 
     // Monthly q greater than unity.
-    q_m[q_m.size() - 1] = 1.001;
+    q_m.back() = 1.001;
     BOOST_TEST_THROW(instantiate_cf(), std::runtime_error, "");
     initialize(0); // Reset.
 
diff --git a/input_sequence.cpp b/input_sequence.cpp
index 18b42fb..e5656a2 100644
--- a/input_sequence.cpp
+++ b/input_sequence.cpp
@@ -82,8 +82,8 @@ InputSequence::InputSequence
     // TODO ?? Not correct if last interval-endpoint specified is not the 
latest of all.
     if(intervals.size()) // TODO ?? And if not?
         {
-        intervals[intervals.size() - 1].end_duration = last_possible_duration;
-        intervals[intervals.size() - 1].end_mode     = e_maturity;
+        intervals.back().end_duration = last_possible_duration;
+        intervals.back().end_mode     = e_maturity;
         }
 
     realize_vector();
diff --git a/test_coding_rules.cpp b/test_coding_rules.cpp
index 2d70a01..368d9c0 100644
--- a/test_coding_rules.cpp
+++ b/test_coding_rules.cpp
@@ -215,7 +215,8 @@ file::file(std::string const& file_path)
         }
 
     data_ = '\n' + data();
-    if('\n' != data().at(data().size() - 1))
+    // The '\n' sentinel just added makes back() safe for 0-byte files:
+    if('\n' != data().back())
         {
         throw std::runtime_error(R"(File does not end in '\n'.)");
         }



reply via email to

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