In the C++ Boost libraries, why is there a quot;.ippquot; extension on some header files(在 C++ Boost 库中,为什么有一个“.ipp?一些头文件的扩展名)
问题描述
在 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"?一些头文件的扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 C++ Boost 库中,为什么有一个“.ipp"?一些头文件的扩展名
基础教程推荐
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- CString 到 char* 2021-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
