Skip to content

Commit 4c24bbd

Browse files
committed
Clean up warnings found in CI
1 parent 8024307 commit 4c24bbd

7 files changed

Lines changed: 15 additions & 73 deletions

code_snippets/chapter05/chapter05_03-002_communication_template.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ class communication
5353

5454
for( ; i < count; ++i)
5555
{
56-
const std::uint8_t by(u >> (i * 8U));
56+
const std::uint8_t by
57+
{static_cast<std::uint8_t>(u >> (i * 8U)) };
5758

5859
if(!send_byte(by))
5960
{

code_snippets/chapter05/chapter05_03-003_communication_session.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ class communication
5151

5252
for( ; i < count; ++i)
5353
{
54-
const std::uint8_t by(u >> (i * 8U));
54+
const std::uint8_t by
55+
{static_cast<std::uint8_t>(u >> (i * 8U)) };
5556

5657
if(!send_byte(by))
5758
{

code_snippets/chapter05/chapter05_08-001_using_the_stl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ auto do_something_with_the_stl() -> void
4141
v.end(),
4242
[](char& c)
4343
{
44-
c = char { c + '0' };
44+
c = char { static_cast<char>(c + '0') };
4545
});
4646

4747
{

code_snippets/chapter05/chapter05_08-002_using_the_stl_algo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void do_something_with_the_stl()
4242
v.begin(),
4343
[](const char& c) -> char
4444
{
45-
return char { c + '0' };
45+
return char { static_cast<char>(c + '0') };
4646
});
4747

4848
{

code_snippets/chapter05/chapter05_13-002_array_to_tuple - Copy.cpp

Lines changed: 0 additions & 59 deletions
This file was deleted.

code_snippets/chapter05/chapter05_13-002_array_to_tuple.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,21 @@ std::array<int, 4> a =
4040
}};
4141

4242
// Convert int array to float tuple.
43-
// Here, the type of t is
43+
// Here, the type of tpl is
4444
// std::tuple<float, float, float, float>.
45-
auto t { array_to_tuple(a) };
45+
std::tuple<float, float, float, float> tpl
46+
{ array_to_tuple(a) };
4647

4748
auto main() -> int;
4849

4950
auto main() -> int
5051
{
5152
std::stringstream strm { };
5253

53-
strm << std::fixed << std::get<0>(t) << '\n';
54-
strm << std::fixed << std::get<1>(t) << '\n';
55-
strm << std::fixed << std::get<2>(t) << '\n';
56-
strm << std::fixed << std::get<3>(t) << '\n';
54+
strm << std::fixed << std::get<0>(tpl) << '\n';
55+
strm << std::fixed << std::get<1>(tpl) << '\n';
56+
strm << std::fixed << std::get<2>(tpl) << '\n';
57+
strm << std::fixed << std::get<3>(tpl) << '\n';
5758

5859
std::cout << strm.str() << std::endl;
5960
}

code_snippets/chapter05/chapter05_13-003_exp_series.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ constexpr auto exp_series(
2121
const floating_point_type x)
2222
-> floating_point_type
2323
{
24-
static_assert(
25-
std::is_floating_point
26-
<floating_point_type>::value);
24+
static_assert(std::is_floating_point_v<floating_point_type>);
2725

2826
floating_point_type term(1.0L);
2927
floating_point_type sum (0.0L);
@@ -33,7 +31,7 @@ constexpr auto exp_series(
3331
sum += term;
3432

3533
term *= x;
36-
term /= i;
34+
term /= static_cast<floating_point_type>(i);
3735
}
3836

3937
return sum;

0 commit comments

Comments
 (0)