Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for a snapshot of the develop branch, built from commit 549cd0dc90.
PrevUpHomeNext

no_exceptions_support

Header <boost/core/no_exceptions_support.hpp>

Authors

  • Pavel Vozenilek

The header <boost/core/no_exceptions_support.hpp> defines macros for use in code that needs to be portable to environments that do not have support for C++ exceptions.

#define BOOST_TRY /*unspecified*/
#define BOOST_CATCH(x) /*unspecified*/
#define BOOST_CATCH_END /*unspecified*/
#define BOOST_RETHROW /*unspecified*/
void foo() {
  BOOST_TRY {
    ...
  } BOOST_CATCH(const std::bad_alloc&) {
      ...
      BOOST_RETHROW
  } BOOST_CATCH(const std::exception& e) {
      ...
  }
  BOOST_CATCH_END
}

With exception support enabled it will expand into:

void foo() {
  { try {
    ...
  } catch (const std::bad_alloc&) {
      ...
      throw;
  } catch (const std::exception& e) {
      ...
  }
  }
}

With exception support disabled it will expand into:

void foo() {
  { if(true) {
    ...
  } else if (false) {
      ...
  } else if (false)  {
      ...
  }
  }
}

PrevUpHomeNext