std::make_e...td::io_errc)(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’… std::make_error_condition(std::io_errc) πŸ’…

okay so this page is from the C++ Standard Libary manual, and it’s giving β€œtiny utility that turns an IO stream error code into an error condition” energy. no cap, it’s short and iconic. πŸ’–


🌸 NAME 🌸

  • std::make_error_condition(std::io_errc) β€” std::make_error_condition(std::io_errc) (yes bestie, the NAME section said it twice, we move πŸ’…)

✨ Synopsis ✨

Defined in header <ios>
std::error_condition make_error_condition( std::io_errc e ) noexcept;

this one is (since C++11), periodt ✨

it constructs an std::error_condition object from a value of type std::io_errc, as if by this exact snippet β€” period and all, bestie, I’m just the messenger 😭:

return std::error_condition(static_cast<int>(e),
       std::iostream_category()).

πŸŽ€ Parameters πŸŽ€

  • e β€” error code number. that’s the whole parameter, lowkey slay.

πŸ’– Return value πŸ’–

A value of type std::error_condition that holds the error code number from e, associated with the error category "iostream". literally that’s it. 🫢

🧚 Example 🧚

       // Run this code

        #include <iostream>
        #include <system_error>

        int main()
        {
            std::error_condition ec =
       std::make_error_condition(std::io_errc::stream);
            std::cout << "error condition for io_errc::stream has value " <<
       ec.value()
                      << "\nand message \"" << ec.message() << "\"\n";
        }

🌈 Output 🌈

error condition for io_errc::stream has value 1
and message "unspecified iostream_category error"

πŸ’… Defect reports πŸ’…

The following behavior-changing defect reports were applied retroactively to previously published C++ standards. yes bestie, this is the lore πŸ“

  • LWG 2087 β€” applied to C++11
    • Behavior as published: make_error_condition(io_errc) was not declared noexcept
    • Correct behavior: declared noexcept

πŸ¦‹ See also πŸ¦‹

  • error_condition β€” holds a portable error code (C++11) (class)
  • io_errc β€” the IO stream error codes (C++11) (enum)

that’s the whole page, bestie 🫢 β€” source/version sign-off: http://cppreference.com, date 2024.06.10, and the footer title std::make_e...td::io_errc)(3). periodt πŸ’…

πŸ“¦ where this page comes from