summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-slicing.rst
diff options
context:
space:
mode:
Diffstat (limited to 'clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-slicing.rst')
-rw-r--r--clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-slicing.rst24
1 files changed, 13 insertions, 11 deletions
diff --git a/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-slicing.rst b/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-slicing.rst
index 94ceb98ca6f..44f3dcaba6c 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-slicing.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-slicing.rst
@@ -5,19 +5,21 @@ cppcoreguidelines-slicing
Flags slicing of member variables or vtable. Slicing happens when copying a
derived object into a base object: the members of the derived object (both
-member variables and virtual member functions) will be discarded.
-This can be misleading especially for member function slicing, for example:
+member variables and virtual member functions) will be discarded. This can be
+misleading especially for member function slicing, for example:
-.. code:: c++
+.. code-block:: c++
- struct B { int a; virtual int f(); };
- struct D : B { int b; int f() override; };
- void use(B b) { // Missing reference, intended ?
- b.f(); // Calls B::f.
- }
- D d;
- use(d); // Slice.
+ struct B { int a; virtual int f(); };
+ struct D : B { int b; int f() override; };
-See the relevant CppCoreGuidelines sections for details:
+ void use(B b) { // Missing reference, intended?
+ b.f(); // Calls B::f.
+ }
+
+ D d;
+ use(d); // Slice.
+
+See the relevant C++ Core Guidelines sections for details:
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es63-dont-slice
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c145-access-polymorphic-objects-through-pointers-and-references
OpenPOWER on IntegriCloud