Does the standard indicate which headings include other headings?

I did an online coding contest, and I decided to find a header that has a shorter name than <iostream>, but includes <iostream>. Well, I still have not succeeded, but it made me think:

Does the standard indicate which headings include other headings?

For example, <iostream> cplusplus says:

The inclusion of this header can automatically include other headers, such as <ios>, <streambuf>, <istream>, <ostream>and / or <iosfwd>.

However, when I search <ios>, there is no such statement as "This title may be included <iostream>." For some headlines, I could imagine that they needed to include others for them to work properly. And if so, I would expect the standard to make some assertion about how the headers depend on each other (for example, circular dependencies should be avoided). Or does the standard simply certify that such dependencies do not exist, and it depends on the implementation?

+4
source share
4 answers

As far as I know, the standard does not indicate which headers include other headers - this is an implementation, not something you should rely on. Include what you are using.

, http://cppreference.com/ http://cplusplus.com/ (IMHO) .

+2

, : , , , , .

17.6.5.1 []

17.6.5.2 [res.on.headers]

1 ++ ++. ++ , . ++, , ++, , .

" , ++", :

  • <utility>, <string>, <array>, <deque>, <forward_list>, <list>, <vector>, <map>, <set>, <unordered_map>, <unordered_set>, <queue>, <stack>, <algorithm>, <random>, <valarray>, <regex> <initializer_list>.
  • <bitset> <string>, <iosfwd>.
  • <iostream> <ios>, <streambuf>, <istream>, <ostream>.
  • <ios> <iosfwd>.

, , , <ios> <iosfwd>, [res.on.headers], . , , .

+2

, , ; , , , .

<initializer_list>; , (, ), .

+1
source

It depends on which version of the standard it belongs to. C ++ 98 and C ++ 03 do not require any header requirements, including other headers.

Starting with C ++ 11 or C ++ 14, the standard indicates that some headers include other headers.

All versions of the standard required to include the same title several times.

So, if you know that you need a specific header, and you are working on a compiler that implements the old standard, just #include the header.

+1
source

Source: https://habr.com/ru/post/1648142/


All Articles