
Update all links to C++ Core Guidelines to `e49158a`.
Refresh done using the following script and some manual edits:
db76e34e74/personal/fred-tingaud/rspec/refresh-cppcoreguidelines.py
When re-using this script, be mindful that:
- it does not cover `shared_content`
- it does not properly escape inline code in links (e.g., "[=]" or "`mutex`es")
- it does not change `C++` to `{cpp}` in link titles.
Co-authored-by: Marco Borgeaud <marco.borgeaud@sonarsource.com>
56 lines
1.3 KiB
Plaintext
56 lines
1.3 KiB
Plaintext
== Why is this an issue?
|
|
|
|
It is possible in the same statement, to declare a user-defined type (``++class++``, ``++struct++``, ``++union++`` or ``++enum++``) followed by variable declarations of this type. But mixing more than one concern in a single statement is confusing for maintainers.
|
|
|
|
|
|
This rule raises an issue when a variable is declared at the end of a user-defined type declaration statement.
|
|
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,cpp]
|
|
----
|
|
struct Container { int size; } container; // Noncompliant
|
|
----
|
|
|
|
|
|
=== Compliant solution
|
|
|
|
[source,cpp]
|
|
----
|
|
struct Container { int size; };
|
|
Container container;
|
|
----
|
|
|
|
|
|
== Resources
|
|
|
|
* {cpp} Core Guidelines - https://github.com/isocpp/CppCoreGuidelines/blob/e49158a/CppCoreGuidelines.md#c7-dont-define-a-class-or-enum-and-declare-a-variable-of-its-type-in-the-same-statement[C.7: Don't define a class or enum and declare a variable of its type in the same statement]
|
|
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
Declare this variable in a separate statement.
|
|
|
|
|
|
=== Highlighting
|
|
|
|
variable name
|
|
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
=== on 17 Jun 2016, 16:43:47 Ann Campbell wrote:
|
|
\[~alban.auzeill] I've simplified the code samples. Please double-check me.
|
|
|
|
endif::env-github,rspecator-view[]
|