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"?一些头文件的扩展名
基础教程推荐
- 随机插入/删除的综合向量与链表基准 2022-01-01
- 将不可复制的闭包对象传递给 std::function 参数 2021-01-01
- C++:获取传递给函数的多维数组的行大小 2021-01-01
- 如何在 C++ 中正确使用命名空间? 2022-01-01
- 如何部分禁用 cmake C/C++ 自定义编译器检查 2021-01-01
- c++ STL设置差异 2022-01-01
- 如何更改 SysDateTimePick32 或 CDateTimeCtrl 的背景颜色? 2022-01-01
- 为什么我们不能使用“虚拟继承"?在 COM 中? 2022-01-01
- 与 CAS 的原子交换(使用 gcc 同步内置函数) 2022-01-01
- 提升 ASIO 流缓冲 2021-01-01
