Chapter 12. inline
Difficulty: 4
Contrary to popular opinion, the keyword inline
is not some sort of magic bullet. It is, however, a useful tool when employed properly. The question is: When should you use it?
What does
inline
do?Does making a function
inline
increase efficiency?When and how should you decide to
inline
a function?
Solution
1. What does
inline
do?
Making a function inline
directs the compiler that it may choose to place a copy of the function's code directly into each place the code is used. In the cases where the compiler does so, it avoids generating a function call.
2. Does making a function
inline
increase efficiency?
Not necessarily. ...
Get More Exceptional C++ now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.