author | William Roberts <williamr@symbian.org> |
Tue, 16 Mar 2010 16:12:26 +0000 | |
branch | Symbian2 |
changeset 2 | 2fe1408b6811 |
permissions | -rw-r--r-- |
williamr@2 | 1 |
#ifndef BOOST_DETAIL_NO_EXCEPTIONS_SUPPORT_HPP_ |
williamr@2 | 2 |
#define BOOST_DETAIL_NO_EXCEPTIONS_SUPPORT_HPP_ |
williamr@2 | 3 |
|
williamr@2 | 4 |
#if (defined _MSC_VER) && (_MSC_VER >= 1200) |
williamr@2 | 5 |
# pragma once |
williamr@2 | 6 |
#endif |
williamr@2 | 7 |
|
williamr@2 | 8 |
//---------------------------------------------------------------------- |
williamr@2 | 9 |
// (C) Copyright 2004 Pavel Vozenilek. |
williamr@2 | 10 |
// Use, modification and distribution is subject to the Boost Software |
williamr@2 | 11 |
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt |
williamr@2 | 12 |
// or copy at http://www.boost.org/LICENSE_1_0.txt) |
williamr@2 | 13 |
// |
williamr@2 | 14 |
// |
williamr@2 | 15 |
// This file contains helper macros used when exception support may be |
williamr@2 | 16 |
// disabled (as indicated by macro BOOST_NO_EXCEPTIONS). |
williamr@2 | 17 |
// |
williamr@2 | 18 |
// Before picking up these macros you may consider using RAII techniques |
williamr@2 | 19 |
// to deal with exceptions - their syntax can be always the same with |
williamr@2 | 20 |
// or without exception support enabled. |
williamr@2 | 21 |
// |
williamr@2 | 22 |
|
williamr@2 | 23 |
/* Example of use: |
williamr@2 | 24 |
|
williamr@2 | 25 |
void foo() { |
williamr@2 | 26 |
BOOST_TRY { |
williamr@2 | 27 |
... |
williamr@2 | 28 |
} BOOST_CATCH(const std::bad_alloc&) { |
williamr@2 | 29 |
... |
williamr@2 | 30 |
BOOST_RETHROW |
williamr@2 | 31 |
} BOOST_CATCH(const std::exception& e) { |
williamr@2 | 32 |
... |
williamr@2 | 33 |
} |
williamr@2 | 34 |
BOOST_CATCH_END |
williamr@2 | 35 |
} |
williamr@2 | 36 |
|
williamr@2 | 37 |
With exception support enabled it will expand into: |
williamr@2 | 38 |
|
williamr@2 | 39 |
void foo() { |
williamr@2 | 40 |
{ try { |
williamr@2 | 41 |
... |
williamr@2 | 42 |
} catch (const std::bad_alloc&) { |
williamr@2 | 43 |
... |
williamr@2 | 44 |
throw; |
williamr@2 | 45 |
} catch (const std::exception& e) { |
williamr@2 | 46 |
... |
williamr@2 | 47 |
} |
williamr@2 | 48 |
} |
williamr@2 | 49 |
} |
williamr@2 | 50 |
|
williamr@2 | 51 |
With exception support disabled it will expand into: |
williamr@2 | 52 |
|
williamr@2 | 53 |
void foo() { |
williamr@2 | 54 |
{ if(true) { |
williamr@2 | 55 |
... |
williamr@2 | 56 |
} else if (false) { |
williamr@2 | 57 |
... |
williamr@2 | 58 |
} else if (false) { |
williamr@2 | 59 |
... |
williamr@2 | 60 |
} |
williamr@2 | 61 |
} |
williamr@2 | 62 |
} |
williamr@2 | 63 |
*/ |
williamr@2 | 64 |
//---------------------------------------------------------------------- |
williamr@2 | 65 |
|
williamr@2 | 66 |
#include <boost/config.hpp> |
williamr@2 | 67 |
#include <boost/detail/workaround.hpp> |
williamr@2 | 68 |
|
williamr@2 | 69 |
#if !(defined BOOST_NO_EXCEPTIONS) |
williamr@2 | 70 |
# define BOOST_TRY { try |
williamr@2 | 71 |
# define BOOST_CATCH(x) catch(x) |
williamr@2 | 72 |
# define BOOST_RETHROW throw; |
williamr@2 | 73 |
# define BOOST_CATCH_END } |
williamr@2 | 74 |
#else |
williamr@2 | 75 |
# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) |
williamr@2 | 76 |
# define BOOST_TRY { if ("") |
williamr@2 | 77 |
# define BOOST_CATCH(x) else if (!"") |
williamr@2 | 78 |
# else |
williamr@2 | 79 |
# define BOOST_TRY { if (true) |
williamr@2 | 80 |
# define BOOST_CATCH(x) else if (false) |
williamr@2 | 81 |
# endif |
williamr@2 | 82 |
# define BOOST_RETHROW |
williamr@2 | 83 |
# define BOOST_CATCH_END } |
williamr@2 | 84 |
#endif |
williamr@2 | 85 |
|
williamr@2 | 86 |
|
williamr@2 | 87 |
#endif |