rspec/rules/S6164/cfamily/rule.adoc
Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

42 lines
715 B
Plaintext

== Why is this an issue?
Starting from {cpp}20, mathematical constants are defined in the header ``++<numbers>++``.
You should prefer using them instead of hardcoding your own constants.
=== Noncompliant code example
[source,cpp]
----
const double pi = 3.14159265358979323846; // Noncompliant
auto computeCirclePerimeter(double radius) {
return 2 * pi * radius;
}
----
=== Compliant solution
[source,cpp]
----
#include <numbers>
auto computeCirclePerimeter(double radius) {
return 2 * std::numbers::pi * radius;
}
----
ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)
=== is related to: S2904
=== is related to: S109
endif::env-github,rspecator-view[]