Skip to content

Commit 4ba7b13

Browse files
committed
docs
1 parent 64c1fcc commit 4ba7b13

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

clang-tools-extra/docs/clang-tidy/checks/bugprone/crtp-constructor-accessibility.rst

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,26 @@
33
bugprone-crtp-constructor-accessibility
44
=======================================
55

6-
Finds CRTP used in an error-prone way.
6+
Finds Curiously Recurring Template Pattern used in an error-prone way.
7+
8+
The CRTP is an idiom, in which a class derives from a template class, where
9+
itself is the template argument. It should be ensured that if a class is
10+
intended to be a base class in this idiom, it can only be instantiated if
11+
the derived class is it's template argument.
12+
13+
Example:
14+
15+
.. code-block:: c++
16+
17+
template <typename T> class CRTP {
18+
private:
19+
CRTP() = default;
20+
friend T;
21+
};
22+
23+
class Derived : CRTP<Derived> {};
24+
25+
Below can be seen some common mistakes that will allow the breaking of the idiom.
726

827
If the constructor of a class intended to be used in a CRTP is public, then
928
it allows users to construct that class on its own.

0 commit comments

Comments
 (0)