Inlining with Static Local Variables

Local static variables can be very problematic for compiler-based inline resolution. Some compilers will refuse to inline any method that contains a static variable declaration. Some compilers will allow statics to be inlined, but then incorrectly create multiple instances of the inlined variable at run-time. There probably are, no doubt, even some compilers that provide the worst of both worlds: they do not inline methods with static variables, but they do create an independent instance of the method within each separately compiled module. Certainly some of this difficulty is the result of a change in the way C++ handles inlined methods. The current language specification requires external linkage of inlined ...

Get Efficient C++ Performance Programming Techniques 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.