aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--_posts/2017-06-24-static-vs-inline-vs-unnamed-namespaces.md34
1 files changed, 17 insertions, 17 deletions
diff --git a/_posts/2017-06-24-static-vs-inline-vs-unnamed-namespaces.md b/_posts/2017-06-24-static-vs-inline-vs-unnamed-namespaces.md
index f58c50a..fca1d7a 100644
--- a/_posts/2017-06-24-static-vs-inline-vs-unnamed-namespaces.md
+++ b/_posts/2017-06-24-static-vs-inline-vs-unnamed-namespaces.md
@@ -45,6 +45,23 @@ snippets:
In this post I'll try to figure out whether I should use `static`, `inline` or
unnamed namespaces for function definitions.
+TL;DR
+-----
+
+Here's my attempt to build an algorithm to decide whether a class/function
+should be defined with either of the `static`/`inline` specifiers or put into
+an unnamed namespace.
+The first question I answer is: is the entity defined in a header file or in a
+.cpp file?
+
+* **In a header** — Is it a class or a function?
+ * **Class** — There's no need to do anything.
+ * **Function** — Do you want it to behave differently for each
+translation unit (may be useful, for example, for logging)?
+ * **Yes** — Use `static`.
+ * **No** — Use `inline`.
+* **In a .cpp file** — Put it into an unnamed namespace.
+
`static`
--------
@@ -210,23 +227,6 @@ of a function/class, including their own local static variables, etc.
* Defining different classes with the same name in different translation units
(without utilizing unnamed namespaces) is undefined behavior.
-Conclusion
-----------
-
-Here's my attempt to build an algorithm to decide whether a class/function
-should be defined with either of the `static`/`inline` specifiers or put into
-an unnamed namespace.
-The first question I answer is: is the entity defined in a header file or in a
-.cpp file?
-
-* **In a header** — Is it a class or a function?
- * **Class** — There's no need to do anything.
- * **Function** — Do you want it to behave differently for each
-translation unit (may be useful, for example, for logging)?
- * **Yes** — Use `static`.
- * **No** — Use `inline`.
-* **In a .cpp file** — Put it into an unnamed namespace.
-
Tricky cases
------------