在C ++ Boost库中,为什么会有&“。ipp& quot;一些头文件的扩展名 [英] In the C++ Boost libraries, why is there a ".ipp" extension on some header files

查看:120
本文介绍了在C ++ Boost库中,为什么会有&“。ipp& quot;一些头文件的扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在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?

推荐答案

解释(来自模板专家之一):

Explanation from one of the template gurus:


如果您想拆分模板源代码到接口和
实现中(有很多充分的理由,包括控制实例化
),您不能很好地两次使用相同的名称
(foo.hpp),和foo.cpp都不适合任何一个。
foo.ipp清楚地将文件描述为旨在$ 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& quot;一些头文件的扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆