C++ inline function

C++ inline function

inline function

When the function call, the caller will pass control of the callee, will carry out the necessary resource allocation, namely overhead.

If this advance preparation time is longer than the execution time than the callee, the call function is obviously uneconomical.

To prevent this from happening, we can be defined as a function inline function. Thus, the compiler will be (selectively) the caller to the callee alternative code, thereby eliminating the process of function calls.

The following code from TensorRT/samples/common/logging.h:

inline LogStreamConsumer LOG_VERBOSE(const Logger& logger)
{
    return LogStreamConsumer(logger.getReportableSeverity(), Severity::kVERBOSE);
}

Shows will be defined as a function of inlinethe way.

Reference Links

Inline Functions in C++

What is “overhead”?

Published 90 original articles · won praise 9 · views 50000 +

Guess you like

Origin blog.csdn.net/keineahnung2345/article/details/104076860