Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

io_errc Enumeration

Visual Studio 2013

Provides symbolic names for the error conditions in <iostream>. Can be used to create error_condition objects to be compared with the value that's returned by the ios_base::failure code() function.

enum class io_errc {
    stream = 1

Both std::make_error_code() and std::make_error_condition() are overloaded for this enum.

ios_base::failure can contain categories of error codes other than error_condition.

// io_errc.cpp
// cl.exe /nologo /W4 /EHsc /MTd

#include <iostream>     

using namespace std;

int main()
    cin.exceptions(ios::failbit | ios::badbit);

    try {
        cin.rdbuf(nullptr); // throws io_errc::stream
    catch (ios::failure& e) {
        cerr << "ios failure caught: ";
        if (e.code() == make_error_condition(io_errc::stream)) {
            cerr << "io_errc stream error condition" << endl;
        else {
            cerr << "unmatched error condition code " << e.code() << endl;
ios failure caught: io_errc stream error condition

Header: <system_error>

Namespace: std

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
© 2014 Microsoft. All rights reserved.