[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master bfe0f4b 2/2: Specify types in full--no implic
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master bfe0f4b 2/2: Specify types in full--no implicit 'int' |
Date: |
Mon, 4 Jun 2018 19:11:49 -0400 (EDT) |
branch: master
commit bfe0f4b5555b2cb1836097ba70d22b30fb38cfd7
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Specify types in full--no implicit 'int'
---
bourn_cast_test.cpp | 8 +++----
census_view.cpp | 24 ++++++++++-----------
multidimgrid_any.cpp | 4 ++--
multidimgrid_tools.cpp | 2 +-
multidimgrid_tools.hpp | 2 +-
rate_table.cpp | 48 ++++++++++++++++++++---------------------
rate_table.hpp | 2 +-
rounding_view_editor.cpp | 4 ++--
rounding_view_editor.hpp | 4 ++--
wx_test_about_version.cpp | 2 +-
wx_test_benchmark_census.cpp | 2 +-
wx_test_calculation_summary.cpp | 10 ++++-----
12 files changed, 56 insertions(+), 56 deletions(-)
diff --git a/bourn_cast_test.cpp b/bourn_cast_test.cpp
index 8fc25ba..7c3e61f 100644
--- a/bourn_cast_test.cpp
+++ b/bourn_cast_test.cpp
@@ -446,7 +446,7 @@ void test_m64_neighborhood()
{
std::cout
<< "test_m64_neighborhood() not run because"
- << "\nunsigned long long is not a 64-bit type."
+ << "\nunsigned long long int is not a 64-bit type."
<< std::endl
;
return;
@@ -837,16 +837,16 @@ int test_main(int, char*[])
,"Cannot cast negative to unsigned."
);
- // Still forbidden even if unsigned type is wider.
+ // Still forbidden even if unsigned type is wider than signed type.
BOOST_TEST_THROW
- (bourn_cast<unsigned long>(std::numeric_limits<signed char>::lowest())
+ (bourn_cast<unsigned long int>(std::numeric_limits<signed
char>::lowest())
,std::runtime_error
,"Cannot cast negative to unsigned."
);
// Still forbidden even if value is only "slightly" negative.
BOOST_TEST_THROW
- (bourn_cast<unsigned long>(-1)
+ (bourn_cast<unsigned long int>(-1)
,std::runtime_error
,"Cannot cast negative to unsigned."
);
diff --git a/census_view.cpp b/census_view.cpp
index 06a7ff8..e586aa3 100644
--- a/census_view.cpp
+++ b/census_view.cpp
@@ -233,9 +233,9 @@ wxWindow* IntSpinRenderer::DoCreateEditor
,rect.GetTopLeft()
,rect.GetSize()
,wxSP_ARROW_KEYS | wxTE_PROCESS_ENTER
- ,static_cast<long>(data.min)
- ,static_cast<long>(data.max)
- ,value_cast<long>(data.value));
+ ,static_cast<long int>(data.min)
+ ,static_cast<long int>(data.max)
+ ,value_cast <long int>(data.value));
}
std::string IntSpinRenderer::DoGetValueFromEditor(wxWindow* editor)
@@ -747,9 +747,9 @@ class CensusViewDataViewModel : public
wxDataViewIndexListModel
wxString GetColumnType(unsigned int col) const override;
- std::string const& col_name(unsigned col) const;
- any_member<Input>& cell_at(unsigned row, unsigned col);
- any_member<Input> const& cell_at(unsigned row, unsigned col) const;
+ std::string const& col_name(unsigned int col) const;
+ any_member<Input>& cell_at(unsigned int row, unsigned int col);
+ any_member<Input> const& cell_at(unsigned int row, unsigned int col) const;
private:
std::vector<std::string> const& all_headers() const;
@@ -757,11 +757,11 @@ class CensusViewDataViewModel : public
wxDataViewIndexListModel
CensusView& view_;
};
-void CensusViewDataViewModel::GetValueByRow(wxVariant& variant, unsigned row,
unsigned col) const
+void CensusViewDataViewModel::GetValueByRow(wxVariant& variant, unsigned int
row, unsigned int col) const
{
if(col == Col_CellNum)
{
- variant = static_cast<long>(1 + row);
+ variant = static_cast<long int>(1 + row);
}
else
{
@@ -773,7 +773,7 @@ void CensusViewDataViewModel::GetValueByRow(wxVariant&
variant, unsigned row, un
}
}
-bool CensusViewDataViewModel::SetValueByRow(wxVariant const& variant, unsigned
row, unsigned col)
+bool CensusViewDataViewModel::SetValueByRow(wxVariant const& variant, unsigned
int row, unsigned int col)
{
LMI_ASSERT(col != Col_CellNum);
@@ -816,18 +816,18 @@ wxString CensusViewDataViewModel::GetColumnType(unsigned
int col) const
}
}
-std::string const& CensusViewDataViewModel::col_name(unsigned col) const
+std::string const& CensusViewDataViewModel::col_name(unsigned int col) const
{
LMI_ASSERT(0 < col);
return all_headers()[col - 1];
}
-inline any_member<Input>& CensusViewDataViewModel::cell_at(unsigned row,
unsigned col)
+inline any_member<Input>& CensusViewDataViewModel::cell_at(unsigned int row,
unsigned int col)
{
return view_.cell_parms()[row][col_name(col)];
}
-inline any_member<Input> const& CensusViewDataViewModel::cell_at(unsigned row,
unsigned col) const
+inline any_member<Input> const& CensusViewDataViewModel::cell_at(unsigned int
row, unsigned int col) const
{
return view_.cell_parms()[row][col_name(col)];
}
diff --git a/multidimgrid_any.cpp b/multidimgrid_any.cpp
index c3380ea..b8ae746 100644
--- a/multidimgrid_any.cpp
+++ b/multidimgrid_any.cpp
@@ -112,7 +112,7 @@ class MultiDimGridGrid
,wxWindowID
,wxPoint const& = wxDefaultPosition
,wxSize const& = wxDefaultSize
- ,long style = 0 // no wxWANTS_CHARS, as is wxGrid's default
+ ,long int style = 0 // no wxWANTS_CHARS, as is wxGrid's default
,std::string const& name = wxPanelNameStr
);
~MultiDimGridGrid() override = default;
@@ -134,7 +134,7 @@ inline MultiDimGridGrid::MultiDimGridGrid
,wxWindowID id
,wxPoint const& pos
,wxSize const& size
- ,long style
+ ,long int style
,std::string const& name
)
:wxGrid(parent, id, pos, size, style, name)
diff --git a/multidimgrid_tools.cpp b/multidimgrid_tools.cpp
index 8c8be7b..b3af96c 100644
--- a/multidimgrid_tools.cpp
+++ b/multidimgrid_tools.cpp
@@ -66,7 +66,7 @@ AutoResizingTreeCtrl::AutoResizingTreeCtrl
,wxWindowID id
,wxPoint const& pos
,wxSize const& size
- ,long style
+ ,long int style
,wxValidator const& validator
)
:wxTreeCtrl(parent, id, pos, size, style, validator)
diff --git a/multidimgrid_tools.hpp b/multidimgrid_tools.hpp
index f00585f..6c4dd7c 100644
--- a/multidimgrid_tools.hpp
+++ b/multidimgrid_tools.hpp
@@ -428,7 +428,7 @@ class AutoResizingTreeCtrl
,wxWindowID
,wxPoint const& = wxDefaultPosition
,wxSize const& = wxDefaultSize
- ,long style = wxTR_HAS_BUTTONS
+ ,long int style = wxTR_HAS_BUTTONS
,wxValidator const& = wxDefaultValidator
);
diff --git a/rate_table.cpp b/rate_table.cpp
index 81fb9f9..403c9a0 100644
--- a/rate_table.cpp
+++ b/rate_table.cpp
@@ -225,7 +225,7 @@ void remove_nothrow(fs::path const& path)
// field of the struct is filled with the parsed value.
struct parse_result
{
- unsigned long long num = 0;
+ unsigned long long int num = 0;
char const* end = nullptr;
};
@@ -846,7 +846,7 @@ class table_impl final
void name(std::string const& name) { name_ = name; }
std::uint32_t number() const { return *number_; }
std::string const& name() const { return *name_; }
- unsigned long compute_hash_value() const;
+ unsigned long int compute_hash_value() const;
private:
table_impl(table_impl const&) = delete;
@@ -910,10 +910,10 @@ class table_impl final
);
// Parse number checking that it is less than the given maximal value.
- static unsigned long do_parse_number
+ static unsigned long int do_parse_number
(enum_soa_field field
,int line_num
- ,unsigned long max_num
+ ,unsigned long int max_num
,std::string const& value
);
@@ -969,7 +969,7 @@ class table_impl final
// values and the select period and max select age if specified.
//
// Throws if minimum or maximum ares are not defined or are invalid.
- unsigned get_expected_number_of_values() const;
+ unsigned int get_expected_number_of_values() const;
// Implementations of the public factory functions.
void read_from_binary(std::istream& is, std::uint32_t offset);
@@ -1181,7 +1181,7 @@ void table_impl::read_number_before_values
read_number(onum, field, ifs, length);
}
-unsigned table_impl::get_expected_number_of_values() const
+unsigned int table_impl::get_expected_number_of_values() const
{
throw_if_missing_field(min_age_, e_field_min_age);
throw_if_missing_field(max_age_, e_field_max_age);
@@ -1203,7 +1203,7 @@ unsigned table_impl::get_expected_number_of_values() const
// Considering that max age is a 16 bit number and int, used for
// computations, is at least 32 bits, there is no possibility of integer
// overflow here.
- unsigned num_values = *max_age_ - *min_age_ + 1;
+ unsigned int num_values = *max_age_ - *min_age_ + 1;
// We are liberal in what we accept and use the default values for the
// selection period and max select age because we don't need them, strictly
@@ -1229,20 +1229,20 @@ unsigned table_impl::get_expected_number_of_values()
const
// In a further application of Postel's law, we consider non-specified
// or 0 maximum select age as meaning "unlimited".
- unsigned effective_max_select = get_value_or(max_select_age_, 0);
+ unsigned int effective_max_select = get_value_or(max_select_age_, 0);
if(effective_max_select == 0)
{
effective_max_select = *max_age_;
}
- unsigned select_range = effective_max_select - *min_age_ + 1;
+ unsigned int select_range = effective_max_select - *min_age_ + 1;
// Maximum possible select_range value is 2^16 and multiplying it by
- // also 16 bit select_period_ still fits in a 32 bit unsigned value, so
- // there is no risk of overflow here neither.
+ // also 16 bit select_period_ still fits in a 32 bit unsigned int
+ // value, so there is no risk of overflow here neither.
select_range *= *select_period_;
- if(std::numeric_limits<unsigned>::max() - num_values < select_range)
+ if(std::numeric_limits<unsigned int>::max() - num_values <
select_range)
{
alarum()
<< "too many values in the table with maximum age " <<
*max_age_
@@ -1268,7 +1268,7 @@ void table_impl::read_values(std::istream& ifs,
std::uint16_t /* length */)
// tables occurring in real-world. Because of this we don't trust the
// length field from the file at all but deduce the number of values from
// the previously specified age-related fields instead.
- unsigned const num_values = get_expected_number_of_values();
+ unsigned int const num_values = get_expected_number_of_values();
values_.resize(num_values);
if(!stream_read(ifs, &values_[0], num_values * sizeof(double)))
@@ -1309,10 +1309,10 @@ std::string* table_impl::parse_string
return &ostr.operator *();
}
-unsigned long table_impl::do_parse_number
+unsigned long int table_impl::do_parse_number
(enum_soa_field field
,int line_num
- ,unsigned long max_num
+ ,unsigned long int max_num
,std::string const& value
)
{
@@ -1341,7 +1341,7 @@ unsigned long table_impl::do_parse_number
;
}
- return static_cast<unsigned long>(res.num);
+ return static_cast<unsigned long int>(res.num);
}
template<typename T>
@@ -1406,8 +1406,8 @@ void table_impl::parse_select_header(std::istream& is,
int& line_num) const
}
std::istringstream iss(line);
- unsigned actual;
- for(unsigned expected = 1; iss >> actual; ++expected)
+ unsigned int actual;
+ for(unsigned int expected = 1; iss >> actual; ++expected)
{
if(actual != expected)
{
@@ -1638,7 +1638,7 @@ void table_impl::skip_spaces
// where "s" is the max select age and "m" is the max age (min age here is 1).
void table_impl::parse_values(std::istream& is, int& line_num)
{
- unsigned const num_values = get_expected_number_of_values();
+ unsigned int const num_values = get_expected_number_of_values();
values_.reserve(num_values);
if(!num_decimals_)
@@ -2228,7 +2228,7 @@ bool table_impl::is_equal(table_impl const& other) const
;
}
-unsigned long table_impl::compute_hash_value() const
+unsigned long int table_impl::compute_hash_value() const
{
// This is a bug-for-bug reimplementation of the hash value computation
// algorithm used in the original SOA format which produces compatible
@@ -2242,7 +2242,7 @@ unsigned long table_impl::compute_hash_value() const
;
oss << std::fixed << std::setprecision(*num_decimals_);
- unsigned const value_width = *num_decimals_ + 2;
+ unsigned int const value_width = *num_decimals_ + 2;
for(auto const& v : values_)
{
@@ -2330,7 +2330,7 @@ std::string const& table::name() const
return impl_->name();
}
-unsigned long table::compute_hash_value() const
+unsigned long int table::compute_hash_value() const
{
return impl_->compute_hash_value();
}
@@ -2450,7 +2450,7 @@ class database_impl final
// Map allowing efficient table lookup by its number. Its values are
// indices into index_ vector.
- typedef std::map<table::Number, unsigned> NumberToIndexMap;
+ typedef std::map<table::Number, unsigned int> NumberToIndexMap;
NumberToIndexMap index_by_number_;
// Path to the database, used only for the error messages.
@@ -2574,7 +2574,7 @@ void database_impl::read_index(std::istream& index_is)
offset =
from_bytes<std::uint32_t>(&index_record[e_index_pos_offset]);
// Check that the cast to int below is safe.
- if(static_cast<unsigned>(std::numeric_limits<int>::max()) <= number)
+ if(static_cast<unsigned int>(std::numeric_limits<int>::max()) <=
number)
{
alarum()
<< "database index is corrupt: "
diff --git a/rate_table.hpp b/rate_table.hpp
index 741db86..9e50103 100644
--- a/rate_table.hpp
+++ b/rate_table.hpp
@@ -84,7 +84,7 @@ class table
std::string const& name() const;
// Method computing the hash value as used in the original SOA format.
- unsigned long compute_hash_value() const;
+ unsigned long int compute_hash_value() const;
// Comparison with another table: all fields are compared.
bool operator==(table const& other) const;
diff --git a/rounding_view_editor.cpp b/rounding_view_editor.cpp
index 17eeddc..4b7b193 100644
--- a/rounding_view_editor.cpp
+++ b/rounding_view_editor.cpp
@@ -164,7 +164,7 @@ RoundingButtons::RoundingButtons
,wxWindowID id
,wxPoint const& pos
,wxSize const& size
- ,long style
+ ,long int style
,std::string const& name
)
:wxPanel()
@@ -178,7 +178,7 @@ void RoundingButtons::Create
,wxWindowID id
,wxPoint const& pos
,wxSize const& size
- ,long style
+ ,long int style
,wxString const& name
)
{
diff --git a/rounding_view_editor.hpp b/rounding_view_editor.hpp
index 529c433..9207e2f 100644
--- a/rounding_view_editor.hpp
+++ b/rounding_view_editor.hpp
@@ -45,7 +45,7 @@ class RoundingButtons
,wxWindowID id
,wxPoint const& pos = wxDefaultPosition
,wxSize const& size = wxDefaultSize
- ,long style = 0
+ ,long int style = 0
,std::string const& name = wxPanelNameStr
);
RoundingButtons(RoundingButtons const&) = delete;
@@ -57,7 +57,7 @@ class RoundingButtons
,wxWindowID id
,wxPoint const& pos = wxDefaultPosition
,wxSize const& size = wxDefaultSize
- ,long style = 0
+ ,long int style = 0
,wxString const& name = wxPanelNameStr
);
diff --git a/wx_test_about_version.cpp b/wx_test_about_version.cpp
index a76b1fd..74ed199 100644
--- a/wx_test_about_version.cpp
+++ b/wx_test_about_version.cpp
@@ -68,7 +68,7 @@ namespace
// converted to an int value.
int year_from_string(wxString const& s)
{
- unsigned long year;
+ unsigned long int year;
LMI_ASSERT(s.ToCULong(&year));
LMI_ASSERT(year < INT_MAX);
diff --git a/wx_test_benchmark_census.cpp b/wx_test_benchmark_census.cpp
index 0f9a4fa..e214684 100644
--- a/wx_test_benchmark_census.cpp
+++ b/wx_test_benchmark_census.cpp
@@ -78,7 +78,7 @@ class census_benchmark
wxString ms_text;
LMI_ASSERT(status_text.EndsWith(" milliseconds", &ms_text));
- long time_real;
+ long int time_real;
LMI_ASSERT(ms_text.ToLong(&time_real));
wxPrintf
diff --git a/wx_test_calculation_summary.cpp b/wx_test_calculation_summary.cpp
index 89616fc..6f300d5 100644
--- a/wx_test_calculation_summary.cpp
+++ b/wx_test_calculation_summary.cpp
@@ -153,7 +153,7 @@ class expect_preferences_dialog_base
}
}
- wxComboBox* focus_column_combobox(unsigned n)
+ wxComboBox* focus_column_combobox(unsigned int n)
{
wxWindow* const column_window = wx_test_focus_controller_child
(*dialog_
@@ -314,7 +314,7 @@ LMI_WX_TEST_CASE(calculation_summary)
std::vector<std::string> const&
summary_columns = effective_calculation_summary_columns();
- for(unsigned n = 0; n < number_of_custom_columns; ++n)
+ for(unsigned int n = 0; n < number_of_custom_columns; ++n)
{
wxString const& column =
focus_column_combobox(n)->GetValue();
if(n < summary_columns.size())
@@ -344,7 +344,7 @@ LMI_WX_TEST_CASE(calculation_summary)
set_use_builtin_summary(false);
wxUIActionSimulator ui;
- for(unsigned n = 0; n < total_number_of_columns; ++n)
+ for(unsigned int n = 0; n < total_number_of_columns; ++n)
{
focus_column_combobox(n);
ui.Select(n == 2 ? "NewCashLoan" : empty_column_name);
@@ -375,7 +375,7 @@ LMI_WX_TEST_CASE(calculation_summary)
);
// And all the rest of the columns are (still) empty.
- for(unsigned n = 1; n < total_number_of_columns; ++n)
+ for(unsigned int n = 1; n < total_number_of_columns; ++n)
{
LMI_ASSERT_EQUAL
(focus_column_combobox(n)->GetValue()
@@ -410,7 +410,7 @@ LMI_WX_TEST_CASE(calculation_summary)
,"NewCashLoan"
);
- for(unsigned n = 1; n < total_number_of_columns; ++n)
+ for(unsigned int n = 1; n < total_number_of_columns; ++n)
{
LMI_ASSERT_EQUAL
(focus_column_combobox(n)->GetValue()