问题描述
C ++标准库头文件可能以未指定的方式包含彼此,因此程序员通常不应该依赖于一个头文件包括另一个头文件。然而,在少数情况下,头部被保证包括另一个头部,或者提供否则将需要包括另一个头部的某些功能。
The C++ standard library headers may include each other in unspecified ways, so programmers generally shouldn't depend on one header including another. In a few cases, however, a header is guaranteed to include another header, or make available certain functions that would otherwise require inclusion of another header. What are those cases?
推荐答案
这个答案忽略了C头文件 - < meow.h>
和< cmeow>
。在C ++库头文件(所有引用都是N4582)中:
This answer ignores C headers - both the <meow.h>
and <cmeow>
ones. Of the C++ library headers (all references are to N4582):
< initializer_list>
由
-
< utility>
(§20.2[utility] li>
-
< string>
(§21.3[string.classes]) -
< array>
(§23.3.2[array.syn]) -
< deque>
(§23.3.3[deque.syn]) -
< forward_list>
(§23.3.4[forward_list.syn ]) -
< list>
(§23.3.5[list.syn]) -
< vector>
(§23.3.6[vector.syn]) -
< map> ;
(§23.4.2[associative.map.syn]) -
< set>
§23.4.3[associative.set.syn]) -
< unordered_map>
(§23.5.2[unord.map。 syn]) -
< unordered_set>
(§23.5.3[unord.set.syn]) -
< queue>
(§23.6.2[queue.syn]) -
< stack>
(§23.6.3[stack.syn]) -
< algorithm>
(§25.1[algorithms.general]) -
< random>
(§26.6.2[rand.synopsis] li>
-
< valarray>
(§26.7.1[valarray.syn]) -
< regex>
(§28.4[re.syn])
<utility>
(§20.2 [utility])<string>
(§21.3 [string.classes])<array>
(§23.3.2 [array.syn])<deque>
(§23.3.3 [deque.syn])<forward_list>
(§23.3.4 [forward_list.syn])<list>
(§23.3.5 [list.syn])<vector>
(§23.3.6 [vector.syn])<map>
(§23.4.2 [associative.map.syn])<set>
(§23.4.3 [associative.set.syn])<unordered_map>
(§23.5.2 [unord.map.syn])<unordered_set>
(§23.5.3 [unord.set.syn])<queue>
(§23.6.2 [queue.syn])<stack>
(§23.6.3 [stack.syn])<algorithm>
(§25.1 [algorithms.general])<random>
(§26.6.2 [rand.synopsis])<valarray>
(§26.7.1 [valarray.syn])<regex>
(§28.4 [re.syn])
< iostream>
保证包括< ios>
,< streambuf>
,< istream>
和< ostream>
(§27.4.1[iostream.objects。概述])。
<iostream>
is guaranteed to include <ios>
, <streambuf>
, <istream>
, and <ostream>
(§27.4.1 [iostream.objects.overview]).
< ios>
保证包括< iosfwd&
(§27.5.1[iostreams.base.overview])。
<ios>
is guaranteed to include <iosfwd>
(§27.5.1 [iostreams.base.overview]).
< bitset>
保证包含< string>
和< iosfwd>
(§20.8[template.bitset])。
<bitset>
is guaranteed to include <string>
and <iosfwd>
(§20.8 [template.bitset]).
std :: begin
, std :: end
,C ++ 14 c-
, r -
和 cr -
版本,以及C ++ 17自由功能模板 std :: size
, std :: empty
和 std :: data
名义上驻留在< iterator>
,但如果包括以下任何头文件也可用:< array>
,< deque>
,< forward_list>
,< list& ;
,< map>
,< regex>
,< set>
,< string>
,< unordered_map>
code>< unordered_set> 和< vector>
(§24.7[iterator.range],§24.8[iterator.container ])。
The free function templates std::begin
, std::end
, the C++14 c-
, r-
, and cr-
versions, and the C++17 free function templates std::size
, std::empty
and std::data
nominally reside in <iterator>
, but are also available if any of the following headers is included: <array>
, <deque>
, <forward_list>
, <list>
, <map>
, <regex>
, <set>
, <string>
, <unordered_map>
, <unordered_set>
, and <vector>
(§24.7 [iterator.range], §24.8 [iterator.container]).
这篇关于C ++标准库中的哪些头保证包含另一个头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!