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

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

okay so bestie, this is the C++ Standard Library page for std::make_error_code(std::io_errc) πŸ’–βœ¨ yes the manual name is folded in right here, and we are keeping every single fact while making it cute. periodt.

πŸ’– NAME πŸ’–

std::make_error_code(std::io_errc) β€” the function that constructs an std::error_code from an std::io_errc value. slay.

✨ Synopsis ✨

Defined in header <ios> β€” and this signature has been iconic since C++11:

std::error_code make_error_code( std::io_errc e ) noexcept;

(since C++11)

Constructs an std::error_code object from a value of type std::io_errc as if by:

return std::error_code(static_cast<int>(e), std::iostream_category());

This function is called by the constructor of std::error_code with an std::io_errc argument. no cap, that’s the whole vibe.

πŸŽ€ Parameters πŸŽ€

  • e β€” error code number

πŸ¦‹ Return value πŸ¦‹

A value of type std::error_code that holds the error code number from e associated with the error category "iostream". literally that.

🌸 Example 🌸

the original says // Run this code β€” here’s the code, bestie:

#include <iostream>
#include <system_error>

int main()
{
    std::error_code ec = std::make_error_code(std::io_errc::stream);

    // This works because of the overloaded method
    //    and the is_error_code_enum specialization.
    ec = std::io_errc::stream;

    std::cout << "Error code from io_errc::stream has category "
              << ec.category().name() << '\n';
}

πŸ“ Output πŸ“

Error code from io_errc::stream has category iostream

🩹 Defect reports 🩹

The following behavior-changing defect reports were applied retroactively to previously published C++ standards. iykyk, we keep the receipts:

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

πŸ‘€ See also πŸ‘€

  • error_code (C++11) (class) β€” holds a platform-dependent error code
  • io_errc (C++11) (enum) β€” the IO stream error codes
  • make_error_code(std::errc) (C++11) (function) β€” creates error code value for errc enum e
  • make_error_code(std::future_errc) (C++11) (function) β€” constructs a future error code

πŸ’Œ cute sign-off: source is http://cppreference.com, version/date is 2024.06.10, and the footer’s title column is std::make_e...d::io_errc)(3). that’s the footer, but make it fashion πŸŽ€πŸ’…

πŸ“¦ where this page comes from