Skip to content

Commit b9af9ca

Browse files
fix: Fix compile errors in ex03
1 parent ed9e87e commit b9af9ca

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

examples/ex03_value_policy.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ int main() {
2929
policy::error::expected>;
3030

3131
// Same overflow input for all three policies.
32-
auto const lhs_checked = checked_t{65530};
33-
auto const rhs_checked = checked_t{20};
32+
auto const lhs_checked = checked_t{static_cast<std::uint16_t>(65530)};
33+
auto const rhs_checked = checked_t{static_cast<std::uint16_t>(20)};
3434
auto const checked_result = operations::add(lhs_checked, rhs_checked);
3535

36-
auto const lhs_unchecked = unchecked_t{65530};
37-
auto const rhs_unchecked = unchecked_t{20};
36+
auto const lhs_unchecked = unchecked_t{static_cast<std::uint16_t>(65530)};
37+
auto const rhs_unchecked = unchecked_t{static_cast<std::uint16_t>(20)};
3838
auto const unchecked_result = operations::add(lhs_unchecked, rhs_unchecked);
3939

40-
auto const lhs_saturating = saturating_t{65530};
41-
auto const rhs_saturating = saturating_t{20};
40+
auto const lhs_saturating = saturating_t{static_cast<std::uint16_t>(65530)};
41+
auto const rhs_saturating = saturating_t{static_cast<std::uint16_t>(20)};
4242
auto const saturating_result =
4343
operations::add(lhs_saturating, rhs_saturating);
4444

@@ -48,11 +48,13 @@ int main() {
4848
std::cerr << "checked policy should report overflow\n";
4949
return 1;
5050
}
51-
if (!unchecked_result.has_value() || unchecked_result->value() != 14) {
51+
if (!unchecked_result.has_value() ||
52+
unchecked_result->value() != static_cast<std::uint16_t>(14)) {
5253
std::cerr << "unchecked policy should wrap\n";
5354
return 1;
5455
}
55-
if (!saturating_result.has_value() || saturating_result->value() != 65535) {
56+
if (!saturating_result.has_value() ||
57+
saturating_result->value() != static_cast<std::uint16_t>(65535)) {
5658
std::cerr << "saturating policy should clamp\n";
5759
return 1;
5860
}

0 commit comments

Comments
 (0)