Name
inline specifier — Inline function specifier
Synopsis
function-specifier := inline
The inline
function specifier
can be used with any function or member function to hint to the
compiler that the function should be expanded inline at the point of
call. The compiler is free to ignore the hint. The compiler is also
free to expand functions inline that are declared without the inline
specifier, so long as this does not
affect the semantics of the program.
An inline function must be defined in the same source file where it is used, before it is used. An inline function can be defined in more than one file (unlike other functions); the definition in every file must be the same.
A member function that is defined within a class definition is
implicitly declared inline
.
Example
struct point {inline
point(int x, int y) : x_(x), y_(y) {} // Redundantinline
point( ); private: int x_, y_; };inline
point::point( ) : x_(0), y_(0) {}
See Also
class
, declaration, function, type, Chapter
5
Get C++ In a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.