I just noted this point in the Google C ++ Coding Style Guide, and I didn't quite understand it.
Take this guide with a pinch of salt. Many of the guidelines are designed to help you interact with the legacy Google codebase and are not particularly good tips for general C ++ development.
So why are there any such -inl.h files?
There is no particular good reason; I donโt do it myself. Some people like it because it minimizes the amount of material in the main header file that the header users usually want to read, and separates implementation details that they usually don't care about.
Also, why do we want to embed long functions at all?
Sometimes we have to: template definitions should be available in any translation unit that creates the template instance, so they (usually) should be in the headers.
Sometimes we want: implementing the inline function in the header, we do not need to worry about creating and creating a separate translation unit for it. This may make it more convenient to distribute the library; possibly due to longer assembly time.
Mike seymour
source share