Skip to content

Commit

Permalink
Add introduction
Browse files Browse the repository at this point in the history
  • Loading branch information
loic-joly-sonarsource committed Dec 19, 2024
1 parent 3e8152b commit f376942
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion rules/S7172/cfamily/rule.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
This rule raises an issue when `std::optional`, `boost::optional`, or `std::expected` wrap a basic type, and a conversion from the wrapper type to `bool` is used to test the presence of a contained value.

== Why is this an issue?

Expand All @@ -13,7 +14,7 @@ if(flag.has_value()) { ... }

When the contained type is also convertible to `bool`, using this concise syntax can be confusing. What is tested: The wrapper, or the contained value?

This rule raises an issue when `std::optional`, `boost::optional`, or `std::expected` wrap a basic type, and the conversion to `bool` is used to test presence of the value.
This rule raises an issue when `std::optional`, `boost::optional`, or `std::expected` wrap a basic type, and the conversion to `bool` is used to test the presence of the value.

=== What is the potential impact?

Expand Down

0 comments on commit f376942

Please sign in to comment.