Dune Core Modules (unstable)

forceinline.hh File Reference

Provide the macro DUNE_FORCE_INLINE that expands to attribute always_inline or similar depending on the compiler (version). More...

Go to the source code of this file.

Detailed Description

Provide the macro DUNE_FORCE_INLINE that expands to attribute always_inline or similar depending on the compiler (version).

Some information is extracted from https://meghprkh.github.io/blog/posts/c++-force-inline.

The effect of DUNE_FORCE_INLINE is typically as follows:

  • Inlining heuristics are disabled and inlining is always attempted regardless of optimization level.
  • Ignore -fno-inline
  • Ignore the inlining limits hence inlining the function regardless. It also inlines functions with allocation calls, which inline keyword never does.

Even when marked with DUNE_FORCE_INLINE, the compiler cannot always inline a function. Examples for such exceptions are

  • The function is virtual and is called virtually.
  • The program calls a function indirectly via a pointer to the function.
  • The function uses a variable argument list.

Example:

DUNE_FORCE_INLINE int maxInt (int a, int b) { return a < b ? b : a; }
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Nov 2, 23:43, 2025)