Is it unspecified whether a standard library header includes arbitrary headers?

纵饮孤独 提交于 2019-12-05 03:32:16

Given that [res.on.headers] is found in the C++14 standard under

17 Library Introduction

17.6 Library-wide requirements

17.6.5 Conforming implementations

17.6.5.2 Headers

it seems safe to say that "C++ headers" in this paragraph means C++ standard library headers. The term is to be understood as opposed to C headers (i.e., those cargo-culted from the C standard library), which are less free in this regard. [res.on.headers] says about them:

The C standard headers (D.5) shall include only their corresponding C++ standard header, as described in 17.6.1.2.

Since a C++ standard library header may include other C++ standard library headers, the contents of any other standard library header may become known after including another, but unless it is stated that a header must include another header, this is not reliable. Whether one header must include another is defined on a header-by-header basis. For example, for <iostream> it says in [iostream.objects.overview] (27.4.1):

Header <iostream> synopsis

#include <ios>
#include <streambuf>
#include <istream>
#include <ostream>

(...)

And in [template.bitset] (20.7)

Header <bitset> synopsis

#include <string>
#include <iosfwd>        // for istream, ostream

(...)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!