Namespaces
Variants
Views
Actions

std::basic_ios::exceptions

From cppreference.com
< cpp‎ | io‎ | basic ios
Revision as of 02:16, 8 December 2012 by Bazzy (Talk | contribs)

Template:ddcl list begin <tr class="t-dcl ">

<td class="t-dcl-nopad">
std::ios_base::iostate exceptions() const;
</td>

<td class="t-dcl-nopad"> </td> <td class="t-dcl-nopad"> </td> </tr> <tr class="t-dcl ">

<td class="t-dcl-nopad">
void exceptions(std::ios_base::iostate except);
</td>

<td class="t-dcl-nopad"> </td> <td class="t-dcl-nopad"> </td> </tr> Template:ddcl list end

Parameters

except - exception mask

Example

#include <iostream>
#include <fstream>
 
int main() {
    int ivalue;
    try {
        std::ifstream in("in.txt");
        in.exceptions(std::ifstream::failbit);
        in >> ivalue;
    } catch (std::ios_base::failure &fail) {
        // handle exception here
    }
}