Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/io/io errc/make error condition"

From cppreference.com
< cpp‎ | io‎ | io errc
m (Update links.)
(Added LWG issue #2087 DR (part 3/3).)
 
(7 intermediate revisions by 6 users not shown)
Line 1: Line 1:
 
{{cpp/title|make_error_condition{{dsc small|(std::io_errc)}}}}
 
{{cpp/title|make_error_condition{{dsc small|(std::io_errc)}}}}
 
{{cpp/io/io_errc/navbar}}
 
{{cpp/io/io_errc/navbar}}
{{ddcl | header=ios | notes={{mark since c++11}}|
+
{{ddcl|header=ios|since=c++11|
std::error_condition make_error_condition( std::io_errc e );
+
std::error_condition make_error_condition( std::io_errc e ) noexcept;
 
}}
 
}}
  
Line 9: Line 9:
 
===Parameters===
 
===Parameters===
 
{{par begin}}
 
{{par begin}}
{{par | e | error code number}}
+
{{par|e|error code number}}
 
{{par end}}
 
{{par end}}
  
 
===Return value===
 
===Return value===
A value of type {{lc|std::error_condition}} that holds the error code number from {{tt|e}} associated with the error category {{c|"iostream"}}.
+
A value of type {{lc|std::error_condition}} that holds the error code number from {{c|e}} associated with the error category {{c|"iostream"}}.
  
 
===Example===
 
===Example===
 
{{example
 
{{example
|
+
|code=
| code=
+
 
#include <iostream>
 
#include <iostream>
 
#include <system_error>
 
#include <system_error>
 +
 
int main()
 
int main()
 
{
 
{
     std::error_condition ec = std::make_error_condition(std::io_errc::stream);
+
     std::error_condition ec = std::make_error_condition(std::io_errc::stream);
 
     std::cout << "error condition for io_errc::stream has value " << ec.value()
 
     std::cout << "error condition for io_errc::stream has value " << ec.value()
 
               << "\nand message \"" << ec.message() << "\"\n";
 
               << "\nand message \"" << ec.message() << "\"\n";
 
}
 
}
| output=
+
|output=
 
error condition for io_errc::stream has value 1
 
error condition for io_errc::stream has value 1
 
and message "unspecified iostream_category error"
 
and message "unspecified iostream_category error"
 
}}
 
}}
 +
 +
===Defect reports===
 +
{{dr list begin}}
 +
{{dr list item|wg=lwg|dr=2087|std=C++11|before={{tt|make_error_condition(io_errc)}} was not declared {{c/core|noexcept}}|after=declared {{c/core|noexcept}}}}
 +
{{dr list end}}
  
 
===See also===
 
===See also===
 
{{dsc begin}}
 
{{dsc begin}}
{{dsc inc | cpp/error/error_condition/dsc make_error_condition}}
+
{{dsc inc|cpp/error/dsc error_condition}}
{{dsc inc | cpp/error/dsc error_condition}}
+
{{dsc inc|cpp/io/dsc io_errc}}
{{dsc inc | cpp/io/dsc io_errc}}
+
 
{{dsc end}}
 
{{dsc end}}
  
[[de:cpp/io/io errc/make error condition]]
+
{{langlinks|de|es|fr|it|ja|pt|ru|zh}}
[[es:cpp/io/io errc/make error condition]]
+
[[fr:cpp/io/io errc/make error condition]]
+
[[it:cpp/io/io errc/make error condition]]
+
[[ja:cpp/io/io errc/make error condition]]
+
[[pt:cpp/io/io errc/make error condition]]
+
[[ru:cpp/io/io errc/make error condition]]
+
[[zh:cpp/io/io errc/make error condition]]
+

Latest revision as of 01:04, 21 August 2023

 
 
 
std::io_errc
Non-member functions
make_error_condition(std::io_errc)
(C++11)
Helper classes
 
Defined in header <ios>
std::error_condition make_error_condition( std::io_errc e ) noexcept;
(since C++11)

Constructs an std::error_condition object from a value of type std::io_errc as if by return std::error_condition(static_cast<int>(e), std::iostream_category()).

Contents

[edit] Parameters

e - error code number

[edit] Return value

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

[edit] Example

#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"

[edit] Defect reports

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

DR Applied to Behavior as published Correct behavior
LWG 2087 C++11 make_error_condition(io_errc) was not declared noexcept declared noexcept

[edit] See also

holds a portable error code
(class) [edit]
(C++11)
the IO stream error codes
(enum) [edit]