inline specifier
Материал из 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. |
[править] Синтаксис
| inline function_declaration | |||||||||
[править] Описание
Встроенный ключевое слово намеками дали компилятору выполнять оптимизацию. Компилятор имеет право на свободу игнорировать этот запрос.
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.
Если компилятор встраивает функции, он заменяет каждый вызов этой функции с реальным телом (без генерации вызова).
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.
Это позволяет избежать дополнительных накладных расходов созданные вызовом функции (размещение данных в стек и извлечения результата), но это может привести к большим исполняемый код функции должен быть повторен несколько раз.
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.
Результат аналогичен Функция подобных макросов
Original:
The result is similar to Функция подобных макросов
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.
Тело функции должны быть видимыми в текущем единицу перевода.
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.
Класс методы, определенные внутри класса тела неявно встроенные.
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.
[править] Пример
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;