|
4 | 4 | \frametitlecpp[98]{Inline keyword}
|
5 | 5 | \begin{block}{Inline functions originally}
|
6 | 6 | \begin{itemize}
|
7 |
| - \item applies to a function to tell the compiler to inline it |
| 7 | + \item Applies to a function to tell the compiler to inline it |
8 | 8 | \begin{itemize}
|
9 |
| - \item i.e. replace function calls by the function's content |
10 |
| - \item similar to a macro |
11 |
| - \end{itemize} |
12 |
| - \item only a hint, compiler can still choose to not inline |
13 |
| - \item avoids function call overhead |
14 |
| - \begin{itemize} |
15 |
| - \item but may increase executable size |
| 9 | + \item That is, replace function calls by the function's content\\ |
| 10 | + (similar to how a macro works) |
16 | 11 | \end{itemize}
|
| 12 | + \item Only a hint, compiler can still choose to not inline |
| 13 | + \item Avoids call overhead at the cost of increasing binary size |
17 | 14 | \end{itemize}
|
18 | 15 | \end{block}
|
19 | 16 | \begin{exampleblock}{Major side effect}
|
20 | 17 | \begin{itemize}
|
21 |
| - \item the linker reduces the duplicated functions into one |
22 |
| - \item an inline function definition can thus live in header files |
| 18 | + \item The linker reduces the duplicated functions into one |
| 19 | + \item An inline function definition can thus live in header files |
23 | 20 | \end{itemize}
|
24 | 21 | \end{exampleblock}
|
25 | 22 | \begin{block}{}
|
|
35 | 32 | \frametitlecpp[98]{Inline keyword}
|
36 | 33 | \begin{block}{Inline functions nowadays}
|
37 | 34 | \begin{itemize}
|
38 |
| - \item compilers can judge far better when to inline or not |
| 35 | + \item Compilers can judge far better when to inline or not |
39 | 36 | \begin{itemize}
|
40 | 37 | \item thus primary purpose is gone
|
41 | 38 | \end{itemize}
|
42 |
| - \item putting functions into headers became main purpose |
43 |
| - \item many types of functions are marked \mintinline{cpp}{inline} by default: |
| 39 | + \item Putting functions into headers became main purpose |
| 40 | + \item Many types of functions are marked \mintinline{cpp}{inline} by default: |
44 | 41 | \begin{itemize}
|
45 |
| - \item class member functions |
46 | 42 | \item function templates
|
47 | 43 | \item \mintinline{cpp}{constexpr} functions
|
| 44 | + \item class member functions |
48 | 45 | \end{itemize}
|
49 | 46 | \end{itemize}
|
50 | 47 | \end{block}
|
|
54 | 51 | \frametitlecpp[17]{Inline keyword}
|
55 | 52 | \begin{block}{Inline variables}
|
56 | 53 | \begin{itemize}
|
57 |
| - \item a global (or \mintinline{cpp}{static} member) variable specified as \mintinline{cpp}{inline} |
58 |
| - \item same side effect, linker merges all occurrences into one |
59 |
| - \item allows to define global variables/constants in headers |
| 54 | + \item Global (or \mintinline{cpp}{static} member) variable specified as \mintinline{cpp}{inline} |
| 55 | + \item Same side effect, linker merges all occurrences into one |
| 56 | + \item Allows to define global variables/constants in headers |
60 | 57 | \end{itemize}
|
61 | 58 | \end{block}
|
62 | 59 | \begin{block}{}
|
|
75 | 72 | \end{block}
|
76 | 73 | \begin{alertblock}{}
|
77 | 74 | \begin{itemize}
|
78 |
| - \item Avoid global variables! Constants are fine. |
| 75 | + \item Avoid global variables! Global constants are fine. |
79 | 76 | \end{itemize}
|
80 | 77 | \end{alertblock}
|
81 | 78 | \end{frame}
|
0 commit comments