From 1a6720996afe3a6741ff9d8c76be839e12e15362 Mon Sep 17 00:00:00 2001 From: Kjetil Olsen Lye Date: Mon, 15 May 2023 11:23:33 +0200 Subject: [PATCH] Switched from size_t to std::size_t in safe_conversion.hpp. --- .../linalg/cuistl/detail/safe_conversion.hpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/opm/simulators/linalg/cuistl/detail/safe_conversion.hpp b/opm/simulators/linalg/cuistl/detail/safe_conversion.hpp index c9d7b2d51..0ccf7c71d 100644 --- a/opm/simulators/linalg/cuistl/detail/safe_conversion.hpp +++ b/opm/simulators/linalg/cuistl/detail/safe_conversion.hpp @@ -21,6 +21,7 @@ +#include #include #include #include @@ -47,21 +48,21 @@ namespace Opm::cuistl::detail * @todo This can be done for more generic types, but then it is probably wise to wait for C++20's cmp-functions */ inline int -to_int(size_t s) +to_int(std::size_t s) { static_assert( std::is_signed_v, "Weird architecture or my understanding of the standard is flawed. Better have a look at this function."); static_assert( - !std::is_signed_v, + !std::is_signed_v, "Weird architecture or my understanding of the standard is flawed. Better have a look at this function."); static_assert( - sizeof(int) <= sizeof(size_t), + sizeof(int) <= sizeof(std::size_t), "Weird architecture or my understanding of the standard is flawed. Better have a look at this function."); - if (s > size_t(std::numeric_limits::max())) { + if (s > std::size_t(std::numeric_limits::max())) { OPM_THROW(std::invalid_argument, fmt::format("Trying to convert {} to int, but it is out of range. Maximum possible int: {}. ", s, @@ -80,18 +81,18 @@ to_int(size_t s) * @throw std::invalid_argument if i is negative. * @todo This can be done for more generic types, but then it is probably wise to wait for C++20's cmp-functions */ -inline size_t +inline std::size_t to_size_t(int i) { static_assert( std::is_signed_v, "Weird architecture or my understanding of the standard is flawed. Better have a look at this function."); static_assert( - !std::is_signed_v, + !std::is_signed_v, "Weird architecture or my understanding of the standard is flawed. Better have a look at this function."); static_assert( - sizeof(int) <= sizeof(size_t), + sizeof(int) <= sizeof(std::size_t), "Weird architecture or my understanding of the standard is flawed. Better have a look at this function."); @@ -99,7 +100,7 @@ to_size_t(int i) OPM_THROW(std::invalid_argument, fmt::format("Trying to convert the negative number {} to size_t.", i)); } - return size_t(i); + return std::size_t(i); } } // namespace Opm::cuistl::detail