简体   繁体   English

在C ++ Boost库中,为什么在某些头文件上有“.ipp”扩展名

[英]In the C++ Boost libraries, why is there a “.ipp” extension on some header files

In the C++ Boost libraries, why is there a ".ipp" extension on some header files? 在C ++ Boost库中,为什么某些头文件中有“.ipp”扩展名?

It seems like they are header files included by the ".hpp" file of the same name. 它们似乎是同名“.hpp”文件中包含的头文件。

Is this convention common outside of Boost? 这个惯例在Boost之外是否常见?

What is the justification for having a special file type? 拥有特殊文件类型的理由是什么?

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.hpp)两次,并且foo.cpp不适合任何一个。 foo.ipp clearly delineates the file as an implementation file intended to be #included in foo.hpp. foo.ipp清楚地将文件描述为foo.hpp中的#included实现文件。

I believe "ipp" stands from "implementation" file. 我相信“ipp”代表“实现”文件。 ie, they hold actually code (for inline functions & templates) rather than just declaration (which are in the header --.H or .HPP -- files) 即,他们实际上持有代码(用于内联函数和模板)而不仅仅是声明(在标题中 - .H或.HPP - 文件)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM