inline specifier
Aus cppreference.com
![]() |
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
[Bearbeiten] Syntax
inline function_declaration | |||||||||
[Bearbeiten] Beschreibung
Das Schlüsselwort inline ist ein Hinweis für den Compiler, eine Optimierung vorzunehmen. Der Compiler kann diese Anforderung jedoch ignorieren.
Original:
The inline keyword is a hint given to the compiler to perform an optimization. The compiler has the freedom to ignore this request.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Wenn der Compiler eine Funktion als inline implementiert, ersetzt er jeden Aufruf dieser Funktion durch den eigentlichen Code (ohne einen Funktionsauruf) .
Original:
If the compiler inlines the function, it replaces every call of that function with the actual body (without generating a call).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Dies vermeidet zusätzlichen Overhead durch den Aufruf der Funktion (Platzierung von Daten auf dem Stack und Abrufen des Ergebnisses), aber es kann zu größeren Binaries führen, da der Funktionscode eventuell mehrfach wiederholt werden muss.
Original:
This avoids extra overhead created by the function call (placing data on stack and retrieving the result) but it may result in a larger executable as the code for the function has to be repeated multiple times.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Das Ergebnis ist ähnlich funktionsähnlichen Makros
Original:
The result is similar to funktionsähnlichen Makros
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Der Funktionscode muss in der aktuellen Übersetzungseinheit verfügbar sein.
Original:
The function body must be visible in the current translation unit.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Methoden, die innerhalb der Klasse definiert werden, werden implizit als inline deklariert.
Original:
Class methods defined inside the class body are implicitly declared inline.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[Bearbeiten] Beispiel
inline int sum(int a, int b) { return (a + b); } int c = sum(1, 4); // if the compiler inlines the function the compiled code will be the same as writing int c = 1 + 4;