Espaces de noms
Variantes
Affichages
Actions

inline specifier

De cppreference.com
< cpp‎ | language

 
 
Langage C++
Sujets généraux
Contrôle de flux
Instructions conditionnelles
Instructions d'itération
Instructions de saut
Fonctions
déclaration de fonction
expression lambda
fonction générique
spécificateur inline
spécification d'exception (obsolète)
spécificateur noexcept (C++11)
Exceptions
Espaces de noms
Types
spécificateur decltype (C++11)
Qualificatifs
qualificatifs const et volatile
qualificatifs de stockage
qualificatif constexpr (C++11)
qualificatif auto (C++11)
qualificatif alignas (C++11)
Initialisation
Littéraux
Expressions
opérateurs alternatifs
Utilitaires
Types
déclaration typedef
déclaration d'alias de type (C++11)
attributs (C++11)
Jette
Original:
Casts
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
conversions implicites
conversion const_cast
conversion static_cast
conversion dynamic_cast
conversion reinterpret_cast
conversions style C et style fonction
Allocation de mémoire
Classes
Qualificatifs spécifiques aux membres de classe
Fonctions membres spéciales
Modèles
classes génériques
fonctions génériques
spécialisation de modèles
paquets de paramètres (C++11)
Divers
Assembleur
 

[modifier] Syntaxe

inline function_declaration

[modifier] Description

Le mot-clé inline est une indication donnée au compilateur d'effectuer une optimisation. Le compilateur a le droit d'ignorer cette demande .
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.
Si le compilateur Inlines la fonction, il remplace chaque appel de cette fonction avec le corps réel (sans générer un appel) .
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.
Ceci évite une charge supplémentaire créée par l'appel de fonction (placer les données sur la pile et récupérer le résultat), mais il peut en résulter une plus grande exécutable comme le code de la fonction doit être répété plusieurs fois .
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.
Le résultat est similaire à fonction de type macros
Original:
The result is similar to fonction de type macros
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Le corps de la fonction doit être visible dans l'unité de traduction en cours .
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.
Les méthodes de classe définies à l'intérieur du corps de la classe sont implicitement déclarée en ligne .
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.

[modifier] Exemple

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;