在C ++ Boost库,为什么会出现一个" .ipp"扩展上的一些头文件 [英] In the C++ Boost libraries, why is there a ".ipp" extension on some header files

查看:216
本文介绍了在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.

本公约共同加速之外吗?

Is this convention common outside of Boost?

什么是有一个特殊的文件类型的理由?

What is the justification for having a special file type?

推荐答案

解释从模板大师之一:

如果你想你的模板来源分成接口和
  实现(有很多很好的理由这样做,包括
  控制实例化),就不能很好地使用相同的名称
  (foo.hpp)两次,Foo.cpp中会不适合任何一个。
  foo.ipp清楚地描述该文件旨在实现文件
  在fo​​o.hpp进行#included。

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"扩展上的一些头文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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