问题描述
在 C++ Boost 库中,为什么某些头文件上有.ipp"扩展名?
In the C++ Boost libraries, why is there a ".ipp" extension on some header files?
它们似乎是包含在同名.hpp"文件中的头文件.
It seems like they are header files included by the ".hpp" file of the same name.
这个约定在 Boost 之外很常见吗?
Is this convention common outside of Boost?
拥有特殊文件类型的理由是什么?
What is the justification for having a special file type?
推荐答案
来自一位模板大师的解释:
如果您想将模板源拆分为界面和实施(有很多很好的理由这样做,包括控制实例化),你不能很好地使用相同的名称(foo.hpp) 两次,foo.cpp 不适合任何一个.foo.ipp 清楚地将该文件描述为一个实现文件,旨在#included 在 foo.hpp 中.
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.
这篇关于在 C++ Boost 库中,为什么有一个“.ipp"?一些头文件的扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)