C++ Utilities  4.13.0
Useful C++ classes and routines such as argument parser, IO and conversion utilities
catchiofailure.cpp
Go to the documentation of this file.
1 #define _GLIBCXX_USE_CXX11_ABI 0
2 // include libstd++ specific header <bits/c++config.h> containing __GLIBCXX__
3 // without including ios already (must be included after setting _GLIBCXX_USE_CXX11_ABI)
4 #include <cstddef>
5 
6 // ensure the old ABI is used under libstd++ < 7 and the new ABI under libstd++ >= 7
7 #if __GLIBCXX__ >= 20170502
8 #undef _GLIBCXX_USE_CXX11_ABI
9 #define _GLIBCXX_USE_CXX11_ABI 1
10 #endif
11 
12 #include "./catchiofailure.h"
13 
14 #include <ios>
15 
16 using namespace std;
17 
18 namespace IoUtilities {
19 
25 const char *catchIoFailure()
26 {
27  try {
28  throw;
29  } catch (const ios_base::failure &e) {
30  return e.what();
31  }
32 }
33 
37 void throwIoFailure(const char *what)
38 {
39  throw ios_base::failure(what);
40 }
41 } // namespace IoUtilities
CPP_UTILITIES_EXPORT void throwIoFailure(const char *what)
Throws a std::ios_base::failure with the specified message.
STL namespace.
Contains utility classes helping to read and write streams.
Definition: binaryreader.h:10
CPP_UTILITIES_EXPORT const char * catchIoFailure()
Provides a workaround for GCC Bug 66145.