@@ -1594,20 +1594,25 @@ Restrict Visibility
15941594^^^^^^^^^^^^^^^^^^^
15951595
15961596Functions and variables should have the most restricted visibility possible.
1597+
15971598For class members, that means using appropriate ``private ``, ``protected ``, or
1598- ``public `` keyword to restrict their access. For non-member functions, variables,
1599- and classes, that means restricting visibility to a single ``.cpp `` file if it's
1600- not referenced outside that file.
1599+ ``public `` keyword to restrict their access.
1600+
1601+ For non-member functions, variables, and classes, that means restricting
1602+ visibility to a single ``.cpp `` file if it is not referenced outside that file.
16011603
16021604Visibility of file-scope non-member variables and functions can be restricted to
16031605the current translation unit by using either the ``static `` keyword or an anonymous
1604- namespace. Anonymous namespaces are a great language feature that tells the C++
1606+ namespace.
1607+
1608+ Anonymous namespaces are a great language feature that tells the C++
16051609compiler that the contents of the namespace are only visible within the current
16061610translation unit, allowing more aggressive optimization and eliminating the
1607- possibility of symbol name collisions. Anonymous namespaces are to C++ as
1608- ``static `` is to C functions and global variables. While ``static `` is available
1609- in C++, anonymous namespaces are more general: they can make entire classes
1610- private to a file.
1611+ possibility of symbol name collisions.
1612+
1613+ Anonymous namespaces are to C++ as ``static `` is to C functions and global
1614+ variables. While ``static `` is available in C++, anonymous namespaces are more
1615+ general: they can make entire classes private to a file.
16111616
16121617The problem with anonymous namespaces is that they naturally want to encourage
16131618indentation of their body, and they reduce locality of reference: if you see a
@@ -1653,10 +1658,17 @@ Avoid putting declarations other than classes into anonymous namespaces:
16531658
16541659 } // namespace
16551660
1656- When you are looking at "``runHelper ``" in the middle of a large C++ file,
1657- you have no immediate way to tell if this function is local to the file. In
1658- contrast, when the function is marked static, you don't need to cross-reference
1659- faraway places in the file to tell that the function is local.
1661+ When you are looking at ``runHelper `` in the middle of a large C++ file,
1662+ you have no immediate way to tell if this function is local to the file.
1663+
1664+ In contrast, when the function is marked static, you don't need to cross-reference
1665+ faraway places in the file to tell that the function is local:
1666+
1667+ .. code-block :: c++
1668+
1669+ static void runHelper() {
1670+ ...
1671+ }
16601672
16611673Don't Use Braces on Simple Single-Statement Bodies of if/else/loop Statements
16621674^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0 commit comments