TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
C++ Coding Standard

Rule:  OPT#003Checked automatically with code checker

This rule is Obsolete
Synopsis:Avoid the usage of inline methods/functions
Severity Level:6
Category:Optimization and Performance


In general usage of inline methods and functions is discouraged. Be aware that the usage of inline code, may result in versioning problems. For example, this may happen for an inline method or function in a dynamic link library. When the implementation of this inline method is changed, but code using the inline method or function is not recompiled, it still uses the old implementation. In other words, replacing the dynamic link library with the latest version on a target machine, will no longer work.

Using inline methods or functions is considered an optimization that is best performed by the compiler. Only in case performance is an issue, the usage of inline may be helpful.

There are a few exceptions to this rule:

  • Local classes, which member functions cannot be defined outside the class definition. Note: a local class is a class that is defined within a function definition. A nested class is a class that is defined within another class. A nested class within a local class is a local class. The mentioned exception does not apply to nested classes that are not local classes.
  • Get and set methods. This is because getters and setters usually have a trivial implementation.
  • Template methods in non-template classes. Some compilers demand that template methods are defined within the class definition in case the class is a non-template class.

Literature References:
Ellemtel Rec. 31
Ellemtel Rec. 45, adapted.
ISC++ Style A. 15