[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 1f1adcf 8/9: Prefer std::array to std::vector
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 1f1adcf 8/9: Prefer std::array to std::vector when size is fixed |
Date: |
Wed, 12 Jun 2019 12:53:01 -0400 (EDT) |
branch: master
commit 1f1adcfce7f982e72c3c4d0333ca650ce91baf2d
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Prefer std::array to std::vector when size is fixed
---
dbindex.hpp | 8 ++++----
dbvalue.cpp | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/dbindex.hpp b/dbindex.hpp
index fde8c39..3ad5d11 100644
--- a/dbindex.hpp
+++ b/dbindex.hpp
@@ -27,7 +27,7 @@
#include "assert_lmi.hpp"
#include "mc_enum_type_enums.hpp"
-#include <vector>
+#include <array>
/// Number of database axes, excluding the special duration axis.
@@ -82,7 +82,7 @@ class database_index
check_issue_age();
}
- std::vector<int> const& index_vector() const {return idx_;}
+ std::array<int,number_of_indices> const& index_array() const {return idx_;}
mcenum_gender gender () const {return static_cast<mcenum_gender
>(idx_[0]);}
mcenum_class uw_class () const {return static_cast<mcenum_class
>(idx_[1]);}
@@ -99,7 +99,7 @@ class database_index
database_index state (mcenum_state z) const {auto i = idx_; i[5] =
z; return {i};}
private:
- database_index(std::vector<int> idx)
+ database_index(std::array<int,number_of_indices> idx)
:idx_ {idx}
{
check_issue_age();
@@ -110,7 +110,7 @@ class database_index
LMI_ASSERT(0 <= issue_age() && issue_age() < e_max_dim_issue_age);
}
- std::vector<int> const idx_;
+ std::array<int,number_of_indices> const idx_;
};
#endif // dbindex_hpp
diff --git a/dbvalue.cpp b/dbvalue.cpp
index 60603f7..39ee57d 100644
--- a/dbvalue.cpp
+++ b/dbvalue.cpp
@@ -277,7 +277,7 @@ double& database_entity::operator[](std::vector<int> const&
index)
double const* database_entity::operator[](database_index const& idx) const
{
- std::vector<int> const& index(idx.index_vector());
+ auto const& index(idx.index_array());
LMI_ASSERT(e_number_of_axes == 1 + index.size());
int z = 0;
- [lmi-commits] [lmi] master updated (a9bcf09 -> d30e9b1), Greg Chicares, 2019/06/12
- [lmi-commits] [lmi] master b6c5d13 6/9: Improve const correctness, Greg Chicares, 2019/06/12
- [lmi-commits] [lmi] master 1f1adcf 8/9: Prefer std::array to std::vector when size is fixed,
Greg Chicares <=
- [lmi-commits] [lmi] master 9ffdf78 4/9: Add const accessors to class database_index, Greg Chicares, 2019/06/12
- [lmi-commits] [lmi] master 7b5da91 5/9: Use database_index const accessors, Greg Chicares, 2019/06/12
- [lmi-commits] [lmi] master fad3d61 1/9: Use forward declarations to improve physical design, Greg Chicares, 2019/06/12
- [lmi-commits] [lmi] master 89c8cc5 2/9: Use forward declarations to improve physical design, Greg Chicares, 2019/06/12
- [lmi-commits] [lmi] master d30e9b1 9/9: Make {{ContractNameCap}} available for all formats, Greg Chicares, 2019/06/12
- [lmi-commits] [lmi] master a8298c9 3/9: Improve list of handy commands, Greg Chicares, 2019/06/12
- [lmi-commits] [lmi] master 8862ffc 7/9: Improve const correctness, Greg Chicares, 2019/06/12