When should I use -inl.h files?

后端 未结 3 798
有刺的猬
有刺的猬 2021-02-14 18:19

I just noted this item in the Google C++ Coding Style Guide - and I don\'t quite get it.

If I put an inline method or function in a file other than the header included b

3条回答
  •  难免孤独
    2021-02-14 18:34

    This is often done for long function templates. The regular header my_functions.h only contains the declarations, and the implementation file my_functions-inl.h contain the implementations. The reason is that function templates cannot be put in .cpp files. Note that the X.h file includes the X-inl.h file, not the other way around.

    Other libraries have different naming conventions: e.g. some of the Boost libraries use .hpp for template headers and .ipp for template implementation files.

提交回复
热议问题