williamr@2: #ifndef BOOST_DETAIL_NO_EXCEPTIONS_SUPPORT_HPP_ williamr@2: #define BOOST_DETAIL_NO_EXCEPTIONS_SUPPORT_HPP_ williamr@2: williamr@2: #if (defined _MSC_VER) && (_MSC_VER >= 1200) williamr@2: # pragma once williamr@2: #endif williamr@2: williamr@2: //---------------------------------------------------------------------- williamr@2: // (C) Copyright 2004 Pavel Vozenilek. williamr@2: // Use, modification and distribution is subject to the Boost Software williamr@2: // License, Version 1.0. (See accompanying file LICENSE_1_0.txt williamr@2: // or copy at http://www.boost.org/LICENSE_1_0.txt) williamr@2: // williamr@2: // williamr@2: // This file contains helper macros used when exception support may be williamr@2: // disabled (as indicated by macro BOOST_NO_EXCEPTIONS). williamr@2: // williamr@2: // Before picking up these macros you may consider using RAII techniques williamr@2: // to deal with exceptions - their syntax can be always the same with williamr@2: // or without exception support enabled. williamr@2: // williamr@2: williamr@2: /* Example of use: williamr@2: williamr@2: void foo() { williamr@2: BOOST_TRY { williamr@2: ... williamr@2: } BOOST_CATCH(const std::bad_alloc&) { williamr@2: ... williamr@2: BOOST_RETHROW williamr@2: } BOOST_CATCH(const std::exception& e) { williamr@2: ... williamr@2: } williamr@2: BOOST_CATCH_END williamr@2: } williamr@2: williamr@2: With exception support enabled it will expand into: williamr@2: williamr@2: void foo() { williamr@2: { try { williamr@2: ... williamr@2: } catch (const std::bad_alloc&) { williamr@2: ... williamr@2: throw; williamr@2: } catch (const std::exception& e) { williamr@2: ... williamr@2: } williamr@2: } williamr@2: } williamr@2: williamr@2: With exception support disabled it will expand into: williamr@2: williamr@2: void foo() { williamr@2: { if(true) { williamr@2: ... williamr@2: } else if (false) { williamr@2: ... williamr@2: } else if (false) { williamr@2: ... williamr@2: } williamr@2: } williamr@2: } williamr@2: */ williamr@2: //---------------------------------------------------------------------- williamr@2: williamr@2: #include williamr@2: #include williamr@2: williamr@2: #if !(defined BOOST_NO_EXCEPTIONS) williamr@2: # define BOOST_TRY { try williamr@2: # define BOOST_CATCH(x) catch(x) williamr@2: # define BOOST_RETHROW throw; williamr@2: # define BOOST_CATCH_END } williamr@2: #else williamr@2: # if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) williamr@2: # define BOOST_TRY { if ("") williamr@2: # define BOOST_CATCH(x) else if (!"") williamr@2: # else williamr@2: # define BOOST_TRY { if (true) williamr@2: # define BOOST_CATCH(x) else if (false) williamr@2: # endif williamr@2: # define BOOST_RETHROW williamr@2: # define BOOST_CATCH_END } williamr@2: #endif williamr@2: williamr@2: williamr@2: #endif