lmi-commits
[Top][All Lists]
Advanced

[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



reply via email to

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