consistently use std::size_t

This commit is contained in:
Arne Morten Kvarving
2023-08-15 09:32:10 +02:00
parent f806e7668b
commit 92fa9577da
64 changed files with 316 additions and 267 deletions

View File

@@ -37,6 +37,7 @@
#include <dune/common/parallel/mpihelper.hh>
#endif
#include <cstddef>
#include <memory>
#include <string_view>
@@ -526,7 +527,7 @@ void handleExtraConvergenceOutput(SimulatorReport& report,
// initialize variables
const auto& initConfig = eclState().getInitConfig();
simtimer_->init(schedule, (size_t)initConfig.getRestartStep());
simtimer_->init(schedule, static_cast<std::size_t>(initConfig.getRestartStep()));
if (this->output_cout_) {
std::ostringstream oss;

View File

@@ -154,9 +154,9 @@ namespace KeywordValidation
const auto& keyword_properties = partially_supported_items.find(keyword.name());
if (keyword_properties != partially_supported_items.end()) {
// If this keyworcs has partially supported items, iterate over all of them.
for (size_t record_index = 0; record_index < keyword.size(); record_index++) {
for (std::size_t record_index = 0; record_index < keyword.size(); record_index++) {
const auto& record = keyword.getRecord(record_index);
for (size_t item_index = 0; item_index < record.size(); item_index++) {
for (std::size_t item_index = 0; item_index < record.size(); item_index++) {
const auto& item = record.getItem(item_index);
// Find the index number, which starts counting at one, so item_index + 1
const auto& item_properties = keyword_properties->second.find(item_index + 1);
@@ -182,8 +182,8 @@ namespace KeywordValidation
void KeywordValidator::validateKeywordItem(const DeckKeyword& keyword,
const PartiallySupportedKeywordProperties<T>& properties,
const bool multiple_records,
const size_t record_index,
const size_t item_index,
const std::size_t record_index,
const std::size_t item_index,
const T& item_value,
std::vector<ValidationError>& errors) const
{

View File

@@ -22,6 +22,7 @@
#include <opm/common/OpmLog/KeywordLocation.hpp>
#include <cstddef>
#include <functional>
#include <initializer_list>
#include <map>
@@ -59,7 +60,7 @@ namespace KeywordValidation
// This is used to list the partially supported items of a keyword:
template <typename T>
using PartiallySupportedKeywordItems = std::map<size_t, PartiallySupportedKeywordProperties<T>>;
using PartiallySupportedKeywordItems = std::map<std::size_t, PartiallySupportedKeywordProperties<T>>;
// This is used to list the keywords that have partially supported items:
template <typename T>
@@ -71,8 +72,8 @@ namespace KeywordValidation
struct ValidationError {
bool critical; // Determines if the encountered problem should be an error or a warning
KeywordLocation location; // Location information (keyword name, file and line number)
size_t record_number; // Number of the offending record
std::optional<size_t> item_number; // Number of the offending item
std::size_t record_number; // Number of the offending record
std::optional<std::size_t> item_number; // Number of the offending item
std::optional<std::string> item_value; // The offending value of a problematic item
std::optional<std::string> user_message; // An optional message to show if a problem is encountered
};
@@ -127,8 +128,8 @@ namespace KeywordValidation
void validateKeywordItem(const DeckKeyword& keyword,
const PartiallySupportedKeywordProperties<T>& properties,
const bool multiple_records,
const size_t record_number,
const size_t item_number,
const std::size_t record_number,
const std::size_t item_number,
const T& item_value,
std::vector<ValidationError>& errors) const;

View File

@@ -331,7 +331,7 @@ fipResv(const Inplace& inplace) const
this->outputResvFluidInPlace_(current_values, 0);
}
for (size_t reg = 1; reg <= inplace.max_region("FIPNUM"); ++reg) {
for (std::size_t reg = 1; reg <= inplace.max_region("FIPNUM"); ++reg) {
std::unordered_map<Inplace::Phase, Scalar> current_values;
for (const auto& phase : Inplace::phases()) {

View File

@@ -96,7 +96,7 @@ void checkSerializedCmdLine(const std::string& current,
std::vector<std::string> only_stored, only_curr;
if (!difference.empty()) {
for (size_t i = 0; i < difference.size(); ) {
for (std::size_t i = 0; i < difference.size(); ) {
auto stored_it = std::find(stored_strings.begin(),
stored_strings.end(), difference[i]);
auto pos = difference[i].find_first_of('=');

View File

@@ -106,7 +106,7 @@ std::pair<std::vector<int>, int> partitionCellsFromFile(const std::string& filen
// Read file into single vector.
std::ifstream is(filename);
const std::vector<int> cellpart{std::istream_iterator<int>(is), std::istream_iterator<int>()};
if (cellpart.size() != size_t(num_cells)) {
if (cellpart.size() != static_cast<std::size_t>(num_cells)) {
auto msg = fmt::format("Partition file contains {} entries, but there are {} cells.",
cellpart.size(), num_cells);
throw std::runtime_error(msg);