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

编程入门 行业动态 更新时间:2024-10-27 12:26:50
本文介绍了标准是否指定哪些标头包括其他标头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在参加一个在线编码竞赛,我的想法是找到一个标题,该标题的名称比< 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.

此外,您可能希望使用 cppreference/而不是 cplusplus/,因为它(IMHO)的质量更高.

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

更多推荐

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

本文发布于:2023-10-11 04:36:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1480702.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:标准

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!