xref: /llvm-project/clang-tools-extra/docs/clang-tidy/checks/modernize/concat-nested-namespaces.rst (revision 32aaacc609e7a0523d498b244e081ac6f3df532b)
1.. title:: clang-tidy - modernize-concat-nested-namespaces
2
3modernize-concat-nested-namespaces
4==================================
5
6Checks for use of nested namespaces such as ``namespace a { namespace b { ... } }``
7and suggests changing to the more concise syntax introduced in C++17: ``namespace a::b { ... }``.
8Inline namespaces are not modified.
9
10For example:
11
12.. code-block:: c++
13
14  namespace n1 {
15  namespace n2 {
16  void t();
17  }
18  }
19
20  namespace n3 {
21  namespace n4 {
22  namespace n5 {
23  void t();
24  }
25  }
26  namespace n6 {
27  namespace n7 {
28  void t();
29  }
30  }
31  }
32
33  // in c++20
34  namespace n8 {
35  inline namespace n9 {
36  void t();
37  }
38  }
39
40Will be modified to:
41
42.. code-block:: c++
43
44  namespace n1::n2 {
45  void t();
46  }
47
48  namespace n3 {
49  namespace n4::n5 {
50  void t();
51  }
52  namespace n6::n7 {
53  void t();
54  }
55  }
56
57  // in c++20
58  namespace n8::inline n9 {
59  void t();
60  }
61
62