fix doc example typo
[boost.git] / boost / detail / no_exceptions_support.hpp
blobd94e35834f710b6c3c7c1964a662f67d4e0f91c2
1 #ifndef BOOST_DETAIL_NO_EXCEPTIONS_SUPPORT_HPP_
2 #define BOOST_DETAIL_NO_EXCEPTIONS_SUPPORT_HPP_
4 #if (defined _MSC_VER) && (_MSC_VER >= 1200)
5 # pragma once
6 #endif
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)
15 // This file contains helper macros used when exception support may be
16 // disabled (as indicated by macro BOOST_NO_EXCEPTIONS).
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.
23 /* Example of use:
25 void foo() {
26 BOOST_TRY {
27 ...
28 } BOOST_CATCH(const std::bad_alloc&) {
29 ...
30 BOOST_RETHROW
31 } BOOST_CATCH(const std::exception& e) {
32 ...
34 BOOST_CATCH_END
37 With exception support enabled it will expand into:
39 void foo() {
40 { try {
41 ...
42 } catch (const std::bad_alloc&) {
43 ...
44 throw;
45 } catch (const std::exception& e) {
46 ...
51 With exception support disabled it will expand into:
53 void foo() {
54 { if(true) {
55 ...
56 } else if (false) {
57 ...
58 } else if (false) {
59 ...
64 //----------------------------------------------------------------------
66 #include <boost/config.hpp>
67 #include <boost/detail/workaround.hpp>
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
87 #endif