source: NonGTP/Boost/boost/detail/no_exceptions_support.hpp @ 857

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