Home >Backend Development >C++ >How do C standard library headers guarantee the inclusion of other headers or provide specific functions without explicit inclusion?

How do C standard library headers guarantee the inclusion of other headers or provide specific functions without explicit inclusion?

Barbara Streisand
Barbara StreisandOriginal
2024-10-29 09:05:30301browse

How do C   standard library headers guarantee the inclusion of other headers or provide specific functions without explicit inclusion?

Headers in the C Standard Library with Guaranteed Inclusions

In most cases, the C standard library headers have unspecified inclusion relationships. However, there are exceptions where specific headers guarantee the inclusion of other headers or provide certain functions without their inclusion.

Headers Guaranteed to Include Specific Headers:

  • Initializer List () is included by:

    • Utility ()
    • String ()
    • Array ()
    • Dequeue ()
    • Forward List ()
    • List ()
    • Vector ()
    • Map ()
    • Set ()
    • Unordered Map ()
    • Unordered Set ()
    • Queue ()
    • Stack ()
    • Algorithm ()
    • Random ()
    • Valarray ()
    • Regex ()
  • Input/Output Stream () includes:

    • Input/Output State ()
    • Stream Buffer ()
    • Input Stream ()
    • Output Stream ()
  • Input/Output State () includes:

    • Forward Declarations ()
  • Bitset () includes:

    • String ()
    • Forward Declarations ()

Headers Guaranteeing Function Availability:

The function templates std::begin, std::end, and their variants (cbegin, crend, etc.) are primarily defined in the Iterator header (). However, they are also available when including any of the following headers:

  • Array ()
  • Dequeue ()
  • Forward List ()
  • List ()
  • Map ()
  • Regex ()
  • Set ()
  • String ()
  • Unordered Map ()
  • Unordered Set ()
  • Vector ()

When including std::string_view (), the functions *begin, *end, and the generic std::swap overloads become available. However, size, empty, and data are not.

The above is the detailed content of How do C standard library headers guarantee the inclusion of other headers or provide specific functions without explicit inclusion?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn