S5408 Remove constexpr static data members from rspec (CPP-5809)
This commit is contained in:
parent
953f1f0315
commit
c83d7bff84
@ -1,7 +1,6 @@
|
|||||||
== Why is this an issue?
|
== Why is this an issue?
|
||||||
|
|
||||||
Declaring a function or a static member variable ``++constexpr++`` makes it implicitly inline.
|
Declaring a function ``++constexpr++`` makes it implicitly inline.
|
||||||
|
|
||||||
|
|
||||||
In that situation, explicitly using the ``++inline++`` keyword would be redundant, and might lead to confusion if it's used in some cases but not others. It's better to simply omit it.
|
In that situation, explicitly using the ``++inline++`` keyword would be redundant, and might lead to confusion if it's used in some cases but not others. It's better to simply omit it.
|
||||||
|
|
||||||
@ -11,22 +10,14 @@ In that situation, explicitly using the ``++inline++`` keyword would be redundan
|
|||||||
[source,cpp]
|
[source,cpp]
|
||||||
----
|
----
|
||||||
inline constexpr int addOne(int n) { return n+1; } // Noncompliant
|
inline constexpr int addOne(int n) { return n+1; } // Noncompliant
|
||||||
struct A {
|
|
||||||
inline constexpr static int secretNumber = 0; // Noncompliant
|
|
||||||
};
|
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|
||||||
=== Compliant solution
|
=== Compliant solution
|
||||||
|
|
||||||
[source,cpp]
|
[source,cpp]
|
||||||
----
|
----
|
||||||
constexpr int addOne(int n) { return n+1; }
|
constexpr int addOne(int n) { return n+1; }
|
||||||
struct A {
|
|
||||||
constexpr static int secretNumber = 0;
|
|
||||||
};
|
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ifdef::env-github,rspecator-view[]
|
ifdef::env-github,rspecator-view[]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user