Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In the C++ Boost libraries, why is there a ".ipp" extension on some header files

Tags:

c++

boost

In the C++ Boost libraries, why is there a ".ipp" extension on some header files?

It seems like they are header files included by the ".hpp" file of the same name.

Is this convention common outside of Boost?

What is the justification for having a special file type?

like image 715
John Mulder Avatar asked Feb 12 '09 21:02

John Mulder


People also ask

What is a .IPP file?

C++ source code file that contains inline functions for a program; wraps functions with a macro that can include or exclude the functions when running a program; used to turn off inlining functions during the debugging process, and turn them back on again for production code.

Is Boost library header-only?

Most Boost libraries are header-only: they consist entirely of header files containing templates and inline functions, and require no separately-compiled library binaries or special treatment when linking. The only Boost libraries that must be built separately are: Boost.


2 Answers

Explanation from one of the template gurus:

If you want to split up your template sources into interface and implementation (there are lots of good reasons to do that, including controlling instantiation), you can't very well use the same name (foo.hpp) twice, and foo.cpp wouldn't be appropriate for either one. foo.ipp clearly delineates the file as an implementation file intended to be #included in foo.hpp.

like image 53
Anonymous Avatar answered Sep 19 '22 13:09

Anonymous


I believe "ipp" stands from "implementation" file. i.e, they hold actually code (for inline functions & templates) rather than just declaration (which are in the header --.H or .HPP -- files)

like image 24
James Curran Avatar answered Sep 21 '22 13:09

James Curran