"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > 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?

Published on 2024-12-23
Browse:969

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.

Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3