Reputation: 45464
I was just curious because in my homework it says that the following statement is false:
The C++ Standard Library functions and classes are not included in every C++ implementation.
I don't think that the Standard Library is included in every C++ implementation unless you add (#include
) the appropriate headers, right? In that case, I think that the above statement is true, not false.
Is the statement true or false?
Upvotes: 1
Views: 400
Reputation: 28737
The statement is true (and your homework instructor is wrong). The standard distinguishes in 17.4.1.3 between hosted and freestanding implementations. Only the hosted implementations are required to implement the C++ standard library. The freestanding implementation is only required to have these headers:
18.1 Types <cstddef>
18.2 Implementation properties <limits>
18.3 Start and termination <cstdlib>
18.4 Dynamic memory management <new>
18.5 Type identification <typeinfo>
18.6 Exception handling <exception>
18.7 Other runtime support <cstdarg>
Upvotes: 3
Reputation: 153820
If the C++ implementation claims to be a conforming implementation of the C++ Standard (ISO/IEC 14882) it needs to include an implementation of both the compiler and the standard C++ library. Even for a conforming implementation the standard library doesn't have to be complete, though: there is a difference between free-standing and hosted implementations. While the former is only required to have very basic support, the latter requires that the entire implementation is provide (I think it is this way around but I keep getting confused about the terms; it may be the other way around).
That said, there are various compilers which don't ship with more than a very basic library and the basic library they ship with consists of things the compiler either has to do or the run-time absolutely need to run. They don't claim to be conforming implementations, however. You would need to combine them with a library but there are several libraries you can purchase (or download, some of them are free but the free ones seem to only work with a couple of specific compilers).
Upvotes: 1
Reputation: 283634
Looks like unfortunate overloading of the word "include".
Your C++ compiler comes with files containing the standard library. So they are "included". But they aren't #include
-d, you have to write #include
in your source files to get access to the standard library.
In addition, there are hosted and freestanding implementations. Here's what the Standard says:
Two kinds of implementations are defined: a hosted implementation and a freestanding implementation. For a hosted implementation, this International Standard defines the set of available libraries. A freestanding implementation is one in which execution may take place without the benefit of an operating system, and has an implementation-defined set of libraries that includes certain language-support libraries (17.6.1.3).
Since the statement says "every C++ implementation", and freestanding implementations do not include the entire C++ Standard Library, the statement is TRUE.
Upvotes: 5