标准是否指定哪些标头包括其他标头? [英] Does the standard specify what headers include other headers?

查看:76
本文介绍了标准是否指定哪些标头包括其他标头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在参加一个在线编码竞赛,我的想法是找到一个标题,该标题的名称比< iostream> 短,但包含< iostream> .好吧,直到现在我都没有提及,但这让我感到奇怪:

I was doing a online coding contest and my idea was to find a header which has a shorter name than <iostream> but includes <iostream>. Well, I didnt suceed until now, but this made me wonder:

标准是否指定哪些标头包括其他标头?

例如,在< iostream> cplusplus 状态:

包含此标头可能会自动包含其他标头,例如< ios> < streambuf> < istream> < ostream> 和/或< iosfwd> .

但是,当我查找< ios> 时,没有这样的语句:"< iostream> 可能包含此标头".对于某些标头,我可以想象它们需要包括其他标头才能正常工作.如果是这种情况,我希望该标准做出一些声明,说明标头如何相互依赖(例如必须避免循环依赖).还是该标准只是确保不存在此类依赖关系并取决于实现?

However, when I look for <ios> there is no such statement as "This header might be included by <iostream>". For some headers I could imagine that they need to include others to work properly. And if this is the case, I would expect the standard to make some statement how the headers depend on each other (e.g. cyclic dependencies have to be avoided). Or does the standard just make sure that such dependencies do not exist and it is up to the implementation?

推荐答案

I 知道,该标准未指定哪些标头包括其他标头-这是实现定义的,不是您应该使用的标头依靠.包括您使用的内容.

As far as I know, the standard does not specify what headers include other headers - that's implementation defined and not something you should ever rely on. Include what you use.

此外,您可能希望使用 http://cppreference.com/而不是

Also, you may want to prefer http://cppreference.com/ over http://cplusplus.com/ as it is (IMHO) of much higher quality.

这篇关于标准是否指定哪些标头包括其他标头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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