[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master f0fd0dc 15/16: Use bourn_cast to convert arit
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master f0fd0dc 15/16: Use bourn_cast to convert arithmetic types safely |
Date: |
Thu, 15 Nov 2018 17:37:05 -0500 (EST) |
branch: master
commit f0fd0dc56b77cdfb5b9718b374ac4220f90eae9c
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Use bourn_cast to convert arithmetic types safely
---
mc_enum.cpp | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/mc_enum.cpp b/mc_enum.cpp
index 62ac13c..fd376e8 100644
--- a/mc_enum.cpp
+++ b/mc_enum.cpp
@@ -23,6 +23,8 @@
#include "mc_enum.hpp"
+#include "bourn_cast.hpp"
+
#include <algorithm> // find()
mc_enum_base::mc_enum_base(int cardinality_of_the_enumeration)
@@ -53,7 +55,10 @@ void mc_enum_base::allow_all(bool b)
int mc_enum_base::first_allowed_ordinal() const
{
- return std::find(allowed_.begin(), allowed_.end(), true) -
allowed_.begin();
+ return bourn_cast<int>
+ ( std::find(allowed_.begin(), allowed_.end(), true)
+ - allowed_.begin()
+ );
}
bool mc_enum_base::is_allowed(int index) const
- [lmi-commits] [lmi] master a1c1aa0 11/16: Avoid type 'long int', (continued)
- [lmi-commits] [lmi] master a1c1aa0 11/16: Avoid type 'long int', Greg Chicares, 2018/11/15
- [lmi-commits] [lmi] master 158c2a1 08/16: Suppress x86_64-linux-gnu gcc-8 diagnostics for xmlwrapp, Greg Chicares, 2018/11/15
- [lmi-commits] [lmi] master db0c484 02/16: Improve default gcc warning options, Greg Chicares, 2018/11/15
- [lmi-commits] [lmi] master d425a61 10/16: Suppress some 86_64-linux-gnu gcc-8 '-Wconversion' diagnostics, Greg Chicares, 2018/11/15
- [lmi-commits] [lmi] master 9c34f2a 12/16: Don't mix std::size_t with fixed-width integer types, Greg Chicares, 2018/11/15
- [lmi-commits] [lmi] master 89e939b 16/16: Prefer lmi::ssize() to member size(), Greg Chicares, 2018/11/15
- [lmi-commits] [lmi] master 0c4c5b6 01/16: Improve gcc dialect defaults, Greg Chicares, 2018/11/15
- [lmi-commits] [lmi] master 96dc6f5 07/16: Suppress certain diagnostics for another old boost library, Greg Chicares, 2018/11/15
- [lmi-commits] [lmi] master 5548922 14/16: Avoid gratuitous use of member size(), Greg Chicares, 2018/11/15
- [lmi-commits] [lmi] master fc8cf69 13/16: Prefer lmi::ssize() to member size(); rewrite a function out of line, Greg Chicares, 2018/11/15
- [lmi-commits] [lmi] master f0fd0dc 15/16: Use bourn_cast to convert arithmetic types safely,
Greg Chicares <=
- [lmi-commits] [lmi] master c0a4dde 04/16: Reliably multiply suseconds_t by double, Greg Chicares, 2018/11/15
- [lmi-commits] [lmi] master 0d09e74 05/16: Make a macro definition conditional, Greg Chicares, 2018/11/15
- [lmi-commits] [lmi] master a00f295 09/16: Avoid std::ptrdiff_t where it's excessively wide for 64-bit builds, Greg Chicares, 2018/11/15