TITLE: non-member inline functions with external linkage (source: comp.std.c++) PROBLEM: clamage@Eng.Sun.COM (Steve Clamage) [...] Instead of a static data object or static class data member, use a function with a local static object. RESPONSE: Jeffrey C. Gealow But this adds the overhead of the function call mechanism to every use of the object. RESPONSE: Rich Paul If you inline the function, are you guarenteed a single instance, or might there be one in each compilation unit, or in each invocation of the function? RESPONSE: clamage@Eng.Sun.COM (Steve Clamage), 10 Apr 96 The ARM was vague on that point, and compilers have differed in their behavior. On the one hand, inline functions are supposed to have the semantics of static functions, meaning a separate copy of the function (and of its static variables) in each translation unit where it is used. On the other hand, it cannot be the case that a class member function exists in several copies; that would violate the One-Definition Rule. The latest draft standard allows for both internal and external linkage of inline functions. All class member functions have external linkage, meaning the program behaves as if only one copy of the function exists in the program. A non-member function may be declared "extern inline": extern inline T& Tobject() { static T t; return t; } This example means the program behaves as if only one copy of the function exists, including any local static data. It is up to the compiler to figure out how to arrange for that to happen. A non-member inline function has internal linkage (behaves like an ordinary static function) if it is not declared "extern". I don't think any compilers support this new set of rules yet, but eventually all compilers will.