@@ -1583,19 +1583,20 @@ Restrict Visibility
1583
1583
^^^^^^^^^^^^^^^^^^^
1584
1584
1585
1585
Functions and variables should have the most restricted visibility possible.
1586
- For class members, that means using appropriate `private `, `protected `, or ` public `
1587
- keyword to restrict their access. For non-member functions, variables, and classes ,
1588
- that means restricting visibility to a single `.cpp ` file if it's not referenced
1589
- outside that file.
1586
+ For class members, that means using appropriate `` private `` , `` protected `` , or
1587
+ `` public `` keyword to restrict their access. For non-member functions, variables,
1588
+ and classes, that means restricting visibility to a single `` .cpp `` file if it's
1589
+ not referenced outside that file.
1590
1590
1591
1591
Visibility of file-scope non-member variables and functions can be restricted to
1592
- the current translation unit by using either the `static ` keyword or an anonymous namespace.
1593
- Anonymous namespaces are a great language feature that tells the C++ compiler that
1594
- the contents of the namespace are only visible within the current translation unit,
1595
- allowing more aggressive optimization and eliminating the possibility of symbol
1596
- name collisions. Anonymous namespaces are to C++ as `static ` is to C functions and
1597
- global variables. While `static ` is available in C++, anonymous namespaces are more
1598
- general: they can make entire classes private to a file.
1592
+ the current translation unit by using either the ``static `` keyword or an anonymous
1593
+ namespace. Anonymous namespaces are a great language feature that tells the C++
1594
+ compiler that the contents of the namespace are only visible within the current
1595
+ translation unit, allowing more aggressive optimization and eliminating the
1596
+ possibility of symbol name collisions. Anonymous namespaces are to C++ as
1597
+ ``static `` is to C functions and global variables. While ``static `` is available
1598
+ in C++, anonymous namespaces are more general: they can make entire classes
1599
+ private to a file.
1599
1600
1600
1601
The problem with anonymous namespaces is that they naturally want to encourage
1601
1602
indentation of their body, and they reduce locality of reference: if you see a
0 commit comments