
On Fri, 5 Mar 2004 20:31:11 +0100 "Pavel Vozenilek" <pavel_vozenilek@hotmail.com> wrote:
After discussion on this topic (very helpful), I suggest to place following code into <boost/throw_exception.hpp>:
#include <boost/detail/workaround.hpp> ...
#if !(defined BOOST_NO_EXCEPTIONS) # define BOOST_TRY { try # define BOOST_CATCH(x) catch(x) # define BOOST_RETHROW throw # define BOOST_CATCH_END } #else # if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) # define BOOST_TRY { if ("") # define BOOST_CATCH(x) else if (!"") # else # define BOOST_TRY if (true) # define BOOST_CATCH else if (false) # endif # define BOOST_RETHROW # define BOOST_CATCH_END } #endif
These macros are NOT intended as recomended practice for users. They exist only to avoid having similar macros in Circular Buffer, Indexed Set and Serialization each.
These macros: - do not produce warnings (VC/Intel/BCB) with or w/o exceptions enabled,- work within if/else statement, - are hopefully ugly enough so users will prefere RAII in application code,- do not conflict within Boost (1.31).
I am not "portability man" but it appears you may have only tested this when both BOOST_NO_EXCEPTIONS is defined and it is for BORLAND, as the third definition of BOOST_TRY is missing the beginning scope marker.