std::make_e...td::io_errc)(3)
π
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 declarednoexcept - Correct behavior: declared
noexcept
- Behavior as published:
π¦ 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
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms