From bd122d3a502b450f04876aabd4630f8de637ecc7 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 14 Aug 2002 12:27:22 +0000 Subject: [PATCH 001/101] BOOST_NO_EXCEPTIONS support added. [SVN r14835] --- include/boost/throw_exception.hpp | 43 +++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 include/boost/throw_exception.hpp diff --git a/include/boost/throw_exception.hpp b/include/boost/throw_exception.hpp new file mode 100644 index 0000000..36e2733 --- /dev/null +++ b/include/boost/throw_exception.hpp @@ -0,0 +1,43 @@ +#ifndef BOOST_THROW_EXCEPTION_HPP_INCLUDED +#define BOOST_THROW_EXCEPTION_HPP_INCLUDED + +#if _MSC_VER >= 1020 +#pragma once +#endif + +// +// boost/throw_exception.hpp +// +// Copyright (c) 2002 Peter Dimov and Multi Media Ltd. +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// + +#include + +#ifdef BOOST_NO_EXCEPTIONS +# include +#endif + +namespace boost +{ + +#ifdef BOOST_NO_EXCEPTIONS + +void throw_exception(std::exception const & e); // user defined + +#else + +template void throw_exception(E const & e) +{ + throw e; +} + +#endif + +} // namespace boost + +#endif // #ifndef BOOST_THROW_EXCEPTION_HPP_INCLUDED From 6c32727296b1016e089170b7fd29fb9461c7a62a Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 14 Nov 2002 15:13:59 +0000 Subject: [PATCH 002/101] boost::throw_exception documentation added. [SVN r16239] --- include/boost/throw_exception.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/boost/throw_exception.hpp b/include/boost/throw_exception.hpp index 36e2733..3f06fcd 100644 --- a/include/boost/throw_exception.hpp +++ b/include/boost/throw_exception.hpp @@ -15,6 +15,8 @@ // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // +// http://www.boost.org/libs/utility/throw_exception.html +// #include From f8e5e0d451fa399fa341fff6e202cc2c5968f148 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 12 Jun 2003 17:09:24 +0000 Subject: [PATCH 003/101] -Wundef fixes. [SVN r18788] --- include/boost/throw_exception.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/throw_exception.hpp b/include/boost/throw_exception.hpp index 3f06fcd..97a2695 100644 --- a/include/boost/throw_exception.hpp +++ b/include/boost/throw_exception.hpp @@ -1,8 +1,8 @@ #ifndef BOOST_THROW_EXCEPTION_HPP_INCLUDED #define BOOST_THROW_EXCEPTION_HPP_INCLUDED -#if _MSC_VER >= 1020 -#pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once #endif // From 400f82c68a86141632d25711a40dee495b5ba74e Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 28 Nov 2003 15:35:21 +0000 Subject: [PATCH 004/101] _MSC_VER use clarified. [SVN r20992] --- include/boost/throw_exception.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/boost/throw_exception.hpp b/include/boost/throw_exception.hpp index 97a2695..e30e238 100644 --- a/include/boost/throw_exception.hpp +++ b/include/boost/throw_exception.hpp @@ -1,6 +1,8 @@ #ifndef BOOST_THROW_EXCEPTION_HPP_INCLUDED #define BOOST_THROW_EXCEPTION_HPP_INCLUDED +// MS compatible compilers support #pragma once + #if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif From 8915934682dbbb25af30e2a72edc527a89f1c3a0 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Mon, 26 Jul 2004 00:32:12 +0000 Subject: [PATCH 005/101] Converted to Boost Software License, Version 1.0 [SVN r24055] --- include/boost/throw_exception.hpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/include/boost/throw_exception.hpp b/include/boost/throw_exception.hpp index e30e238..87bbf13 100644 --- a/include/boost/throw_exception.hpp +++ b/include/boost/throw_exception.hpp @@ -12,10 +12,9 @@ // // Copyright (c) 2002 Peter Dimov and Multi Media Ltd. // -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) // // http://www.boost.org/libs/utility/throw_exception.html // From 4fd93c01b5e7a6399bb17b3ede566c29af820bc1 Mon Sep 17 00:00:00 2001 From: Robert Ramey Date: Wed, 4 Aug 2004 05:15:01 +0000 Subject: [PATCH 006/101] fixes comeau bug [SVN r24278] --- include/boost/throw_exception.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/throw_exception.hpp b/include/boost/throw_exception.hpp index 87bbf13..bb79a37 100644 --- a/include/boost/throw_exception.hpp +++ b/include/boost/throw_exception.hpp @@ -34,7 +34,7 @@ void throw_exception(std::exception const & e); // user defined #else -template void throw_exception(E const & e) +template inline void throw_exception(E const & e) { throw e; } From db3574bc9d69e6bd02084ac48c96519a2c67d27f Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Tue, 4 Mar 2008 01:41:17 +0000 Subject: [PATCH 007/101] boost exception [SVN r43485] --- doc/throw_exception.html | 54 ++++++++++++++++ include/boost/exception/exception.hpp | 90 +++++++++++++++++++++++++++ 2 files changed, 144 insertions(+) create mode 100644 doc/throw_exception.html create mode 100644 include/boost/exception/exception.hpp diff --git a/doc/throw_exception.html b/doc/throw_exception.html new file mode 100644 index 0000000..1a33afd --- /dev/null +++ b/doc/throw_exception.html @@ -0,0 +1,54 @@ + + + + + throw_exception + + + +
+
+
+
+ +

Boost Exception

+
+

throw_exception()

+

#include <boost/throw_exception.hpp>

+
namespace
+boost
+    {
+#ifdef BOOST_NO_EXCEPTIONS
+    void throw_exception( std::exception const & e ); // user defined
+#else
+    template <class E>
+    void throw_exception( E const & e );
+#endif
+    }
+

Effects:

+
  • If BOOST_NO_EXCEPTIONS is not defined, boost::throw_exception(e) is equivalent to throw boost::enable_exception_cloning(boost::enable_error_info(e)), unless BOOST_EXCEPTION_DISABLE is defined, in which case boost::throw_exception(e) is equivalent to throw e;
  • +
  • If BOOST_NO_EXCEPTIONS is defined, the function is left undefined, and the user is expected to supply an appropriate definition. Callers of throw_exception are allowed to assume that the function never returns; therefore, if the user-defined throw_exception returns, the behavior is undefined.
  • +
+

See also:

+ + +
+
+
+ + diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp new file mode 100644 index 0000000..ec1bf1b --- /dev/null +++ b/include/boost/exception/exception.hpp @@ -0,0 +1,90 @@ +//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc. + +//Distributed under the Boost Software License, Version 1.0. (See accompanying +//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef UUID_274DA366004E11DCB1DDFE2E56D89593 +#define UUID_274DA366004E11DCB1DDFE2E56D89593 + +#include +#include +#include + +namespace +boost + { + template + class shared_ptr; + + namespace + exception_detail + { + class error_info_base; + + struct + error_info_container: + public exception_detail::counted_base + { + virtual char const * what( std::type_info const & ) const = 0; + virtual shared_ptr get( std::type_info const & ) const = 0; + virtual void set( shared_ptr const & ) = 0; + }; + } + + template + class error_info; + + template + E const & operator<<( E const &, error_info const & ); + + template + shared_ptr get_error_info( E const & ); + + class + exception + { + public: + + virtual ~exception() throw()=0; + virtual char const * what() const throw(); + + private: + + shared_ptr get( std::type_info const & ) const; + void set( shared_ptr const & ) const; + + template + friend E const & operator<<( E const &, error_info const & ); + + template + friend shared_ptr get_error_info( E const & ); + + intrusive_ptr mutable data_; + }; + + inline + exception:: + ~exception() throw() + { + } + + inline + char const * + exception:: + what() const throw() + { + if( data_ ) + try + { + char const * w = data_->what(typeid(*this)); + BOOST_ASSERT(0!=w); + return w; + } + catch(...) + { + } + return typeid(*this).name(); + } + } + +#endif From f371a6f29d7b53830e6c204589653c85b8affd36 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Tue, 8 Apr 2008 21:29:37 +0000 Subject: [PATCH 008/101] fixed compile errors, removed tabs as required. [SVN r44114] --- include/boost/exception/exception.hpp | 120 +++++++++++++------------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index ec1bf1b..2180d50 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -12,79 +12,79 @@ namespace boost - { - template - class shared_ptr; + { + template + class shared_ptr; - namespace - exception_detail - { - class error_info_base; + namespace + exception_detail + { + class error_info_base; - struct - error_info_container: - public exception_detail::counted_base - { - virtual char const * what( std::type_info const & ) const = 0; - virtual shared_ptr get( std::type_info const & ) const = 0; - virtual void set( shared_ptr const & ) = 0; - }; - } + struct + error_info_container: + public exception_detail::counted_base + { + virtual char const * what( std::type_info const & ) const = 0; + virtual shared_ptr get( std::type_info const & ) const = 0; + virtual void set( shared_ptr const & ) = 0; + }; + } - template - class error_info; + template + class error_info; - template - E const & operator<<( E const &, error_info const & ); + template + E const & operator<<( E const &, error_info const & ); - template - shared_ptr get_error_info( E const & ); + template + shared_ptr get_error_info( E const & ); - class - exception - { - public: + class + exception + { + public: - virtual ~exception() throw()=0; - virtual char const * what() const throw(); + virtual ~exception() throw()=0; + virtual char const * what() const throw(); - private: + private: - shared_ptr get( std::type_info const & ) const; - void set( shared_ptr const & ) const; + shared_ptr get( std::type_info const & ) const; + void set( shared_ptr const & ) const; - template - friend E const & operator<<( E const &, error_info const & ); + template + friend E const & operator<<( E const &, error_info const & ); - template - friend shared_ptr get_error_info( E const & ); + template + friend shared_ptr get_error_info( E const & ); - intrusive_ptr mutable data_; - }; + intrusive_ptr mutable data_; + }; - inline - exception:: - ~exception() throw() - { - } + inline + exception:: + ~exception() throw() + { + } - inline - char const * - exception:: - what() const throw() - { - if( data_ ) - try - { - char const * w = data_->what(typeid(*this)); - BOOST_ASSERT(0!=w); - return w; - } - catch(...) - { - } - return typeid(*this).name(); - } - } + inline + char const * + exception:: + what() const throw() + { + if( data_ ) + try + { + char const * w = data_->what(typeid(*this)); + BOOST_ASSERT(0!=w); + return w; + } + catch(...) + { + } + return typeid(*this).name(); + } + } #endif From df62cf3e0b80a2c7b87973de04a0f50e2f57b8fa Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Tue, 15 Apr 2008 21:56:34 +0000 Subject: [PATCH 009/101] Boost Exception documentation update [SVN r44444] --- doc/throw_exception.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/throw_exception.html b/doc/throw_exception.html index 1a33afd..d26422a 100644 --- a/doc/throw_exception.html +++ b/doc/throw_exception.html @@ -29,12 +29,12 @@ boost #endif }

Effects:

-
  • If BOOST_NO_EXCEPTIONS is not defined, boost::throw_exception(e) is equivalent to throw boost::enable_exception_cloning(boost::enable_error_info(e)), unless BOOST_EXCEPTION_DISABLE is defined, in which case boost::throw_exception(e) is equivalent to throw e;
  • +
    • If BOOST_NO_EXCEPTIONS is not defined, boost::throw_exception(e) is equivalent to throw boost::enable_current_exception(boost::enable_error_info(e)), unless BOOST_EXCEPTION_DISABLE is defined, in which case boost::throw_exception(e) is equivalent to throw e;
    • If BOOST_NO_EXCEPTIONS is defined, the function is left undefined, and the user is expected to supply an appropriate definition. Callers of throw_exception are allowed to assume that the function never returns; therefore, if the user-defined throw_exception returns, the behavior is undefined.

See also:

Boost Exception

+ + +

throw_exception()

+ + +

Effects:

+

Requirements:

+

E must derive publicly from std::exception.

+

Effects:

  • If BOOST_NO_EXCEPTIONS is not defined, boost::throw_exception(e) is equivalent to throw boost::enable_current_exception(boost::enable_error_info(e)), unless BOOST_EXCEPTION_DISABLE is defined, in which case boost::throw_exception(e) is equivalent to throw e;
  • If BOOST_NO_EXCEPTIONS is defined, the function is left undefined, and the user is expected to supply an appropriate definition. Callers of throw_exception are allowed to assume that the function never returns; therefore, if the user-defined throw_exception returns, the behavior is undefined.
From 444048653ff79a0f8497fe8a6e3921e5c95e5547 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 3 May 2008 15:33:06 +0000 Subject: [PATCH 015/101] Fixes for old compilers. [SVN r45069] --- include/boost/throw_exception.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/boost/throw_exception.hpp b/include/boost/throw_exception.hpp index 06194b8..1a57675 100644 --- a/include/boost/throw_exception.hpp +++ b/include/boost/throw_exception.hpp @@ -21,6 +21,15 @@ // #include +#include + +#if !defined( BOOST_EXCEPTION_DISABLE ) && defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, <= 0x551 ) +# define BOOST_EXCEPTION_DISABLE +#endif + +#if !defined( BOOST_EXCEPTION_DISABLE ) && defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, < 1310 ) +# define BOOST_EXCEPTION_DISABLE +#endif #ifdef BOOST_NO_EXCEPTIONS # include From c28501de6c17c58a7a5ac8d14baa3953323a7c22 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Sat, 3 May 2008 19:51:41 +0000 Subject: [PATCH 016/101] Improved compatibility with various compilers. [SVN r45087] --- include/boost/exception/exception.hpp | 76 ++++++++++++++++++--------- 1 file changed, 50 insertions(+), 26 deletions(-) diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index 2180d50..e57d865 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -6,6 +6,8 @@ #ifndef UUID_274DA366004E11DCB1DDFE2E56D89593 #define UUID_274DA366004E11DCB1DDFE2E56D89593 +#include +#include #include #include #include @@ -45,8 +47,46 @@ boost { public: - virtual ~exception() throw()=0; - virtual char const * what() const throw(); + virtual + char const * + what() const throw() + { + if( data_ ) + try + { + char const * w = data_->what(typeid(*this)); + BOOST_ASSERT(0!=w); + return w; + } + catch(...) + { + } + return typeid(*this).name(); + } + + protected: + + exception() + { + } + + exception( exception const & e ): + data_(e.data_) + { + } + +#if BOOST_WORKAROUND( BOOST_MSVC, BOOST_TESTED_AT(1500) ) + //Force class exception to be abstract. + //Otherwise, MSVC bug allows throw exception(), even though the copy constructor is protected. + virtual ~exception() throw()=0; +#else +#if BOOST_WORKAROUND( __GNUC__, BOOST_TESTED_AT(4) ) + virtual //Disable bogus GCC warning. +#endif + ~exception() throw() + { + } +#endif private: @@ -62,29 +102,13 @@ boost intrusive_ptr mutable data_; }; - inline - exception:: - ~exception() throw() - { - } - - inline - char const * - exception:: - what() const throw() - { - if( data_ ) - try - { - char const * w = data_->what(typeid(*this)); - BOOST_ASSERT(0!=w); - return w; - } - catch(...) - { - } - return typeid(*this).name(); - } - } +#if BOOST_WORKAROUND( BOOST_MSVC, BOOST_TESTED_AT(1500) ) //See above. + inline + exception:: + ~exception() throw() + { + } +#endif + } #endif From ca22b615457ef96136f409f4dc24574f53791d52 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 5 May 2008 20:06:58 +0000 Subject: [PATCH 017/101] Unconditionally #include for std::exception. [SVN r45150] --- include/boost/throw_exception.hpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/include/boost/throw_exception.hpp b/include/boost/throw_exception.hpp index 1a57675..36ed0e3 100644 --- a/include/boost/throw_exception.hpp +++ b/include/boost/throw_exception.hpp @@ -22,6 +22,7 @@ #include #include +#include #if !defined( BOOST_EXCEPTION_DISABLE ) && defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, <= 0x551 ) # define BOOST_EXCEPTION_DISABLE @@ -31,13 +32,9 @@ # define BOOST_EXCEPTION_DISABLE #endif -#ifdef BOOST_NO_EXCEPTIONS -# include -#else -# ifndef BOOST_EXCEPTION_DISABLE -# include -# include -# endif +#if !defined( BOOST_NO_EXCEPTIONS ) && !defined( BOOST_EXCEPTION_DISABLE ) +# include +# include #endif namespace boost @@ -45,13 +42,13 @@ namespace boost #ifdef BOOST_NO_EXCEPTIONS -void throw_exception(std::exception const & e); // user defined +void throw_exception( std::exception const & e ); // user defined #else inline void throw_exception_assert_compatibility( std::exception const & ) { } -template inline void throw_exception(E const & e) +template inline void throw_exception( E const & e ) { //All boost exceptions are required to derive std::exception, //to ensure compatibility with BOOST_NO_EXCEPTIONS. From cb55993dbb730123ea39e5839e11fbeb526850f7 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 10 May 2008 19:55:16 +0000 Subject: [PATCH 018/101] Disable Boost.Exception for Borland 5.8.x as well. [SVN r45268] --- include/boost/throw_exception.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/throw_exception.hpp b/include/boost/throw_exception.hpp index 36ed0e3..6555763 100644 --- a/include/boost/throw_exception.hpp +++ b/include/boost/throw_exception.hpp @@ -24,7 +24,7 @@ #include #include -#if !defined( BOOST_EXCEPTION_DISABLE ) && defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, <= 0x551 ) +#if !defined( BOOST_EXCEPTION_DISABLE ) && defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, < 0x590 ) # define BOOST_EXCEPTION_DISABLE #endif From e8fe47ca4e6de9f1b888c841cd69db7d4997185e Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Sun, 11 May 2008 02:15:49 +0000 Subject: [PATCH 019/101] Borland compatibility for enable_error_info.hpp, Tabs removed from exception.hpp, Documentation rebound. [SVN r45273] --- include/boost/exception/exception.hpp | 74 +++++++++++++-------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index e57d865..4129833 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -47,45 +47,45 @@ boost { public: - virtual - char const * - what() const throw() - { - if( data_ ) - try - { - char const * w = data_->what(typeid(*this)); - BOOST_ASSERT(0!=w); - return w; - } - catch(...) - { - } - return typeid(*this).name(); - } + virtual + char const * + what() const throw() + { + if( data_ ) + try + { + char const * w = data_->what(typeid(*this)); + BOOST_ASSERT(0!=w); + return w; + } + catch(...) + { + } + return typeid(*this).name(); + } - protected: + protected: - exception() - { - } + exception() + { + } - exception( exception const & e ): - data_(e.data_) - { - } + exception( exception const & e ): + data_(e.data_) + { + } #if BOOST_WORKAROUND( BOOST_MSVC, BOOST_TESTED_AT(1500) ) - //Force class exception to be abstract. - //Otherwise, MSVC bug allows throw exception(), even though the copy constructor is protected. - virtual ~exception() throw()=0; + //Force class exception to be abstract. + //Otherwise, MSVC bug allows throw exception(), even though the copy constructor is protected. + virtual ~exception() throw()=0; #else #if BOOST_WORKAROUND( __GNUC__, BOOST_TESTED_AT(4) ) - virtual //Disable bogus GCC warning. + virtual //Disable bogus GCC warning. #endif - ~exception() throw() - { - } + ~exception() throw() + { + } #endif private: @@ -103,12 +103,12 @@ boost }; #if BOOST_WORKAROUND( BOOST_MSVC, BOOST_TESTED_AT(1500) ) //See above. - inline - exception:: - ~exception() throw() - { - } + inline + exception:: + ~exception() throw() + { + } #endif - } + } #endif From 6a6f4222cef92be9dda6a3f4a45f05b87c2b3e88 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Wed, 25 Jun 2008 23:27:56 +0000 Subject: [PATCH 020/101] documentation update, added function exception::diagnostic_information, added std::exception to_string overload, removed tabs from source files [SVN r46697] --- doc/throw_exception.html | 23 ++++++++++------- include/boost/exception/exception.hpp | 37 ++++++++++++++++++--------- 2 files changed, 39 insertions(+), 21 deletions(-) diff --git a/doc/throw_exception.html b/doc/throw_exception.html index a45da04..853c8aa 100644 --- a/doc/throw_exception.html +++ b/doc/throw_exception.html @@ -19,28 +19,33 @@ -

throw_exception()

-

#include <boost/throw_exception.hpp>

+

throw_exception

+

#include <boost/throw_exception.hpp>

namespace
 boost
     {
-#ifdef BOOST_NO_EXCEPTIONS
+    #ifdef BOOST_NO_EXCEPTIONS
+    
     void throw_exception( std::exception const & e ); // user defined
-#else
+    
+    #else
+    
     template <class E>
     void throw_exception( E const & e );
-#endif
+    
+    #endif
     }

Requirements:

-

E must derive publicly from std::exception.

+

E must derive publicly from std::exception.

Effects:

-
  • If BOOST_NO_EXCEPTIONS is not defined, boost::throw_exception(e) is equivalent to throw boost::enable_current_exception(boost::enable_error_info(e)), unless BOOST_EXCEPTION_DISABLE is defined, in which case boost::throw_exception(e) is equivalent to throw e;
  • -
  • If BOOST_NO_EXCEPTIONS is defined, the function is left undefined, and the user is expected to supply an appropriate definition. Callers of throw_exception are allowed to assume that the function never returns; therefore, if the user-defined throw_exception returns, the behavior is undefined.
  • +
    • If BOOST_NO_EXCEPTIONS is not defined, boost::throw_exception(e) is equivalent to throw boost::enable_current_exception(boost::enable_error_info(e)), unless BOOST_EXCEPTION_DISABLE is defined, in which case boost::throw_exception(e) is equivalent to throw e;
    • +
    • If BOOST_NO_EXCEPTIONS is defined, the function is left undefined, and the user is expected to supply an appropriate definition. Callers of throw_exception are allowed to assume that the function never returns; therefore, if the user-defined throw_exception returns, the behavior is undefined.

See also:

diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index 4129833..c8a7e72 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -27,7 +27,7 @@ boost error_info_container: public exception_detail::counted_base { - virtual char const * what( std::type_info const & ) const = 0; + virtual char const * diagnostic_information( char const *, std::type_info const & ) const = 0; virtual shared_ptr get( std::type_info const & ) const = 0; virtual void set( shared_ptr const & ) = 0; }; @@ -51,17 +51,14 @@ boost char const * what() const throw() { - if( data_ ) - try - { - char const * w = data_->what(typeid(*this)); - BOOST_ASSERT(0!=w); - return w; - } - catch(...) - { - } - return typeid(*this).name(); + return diagnostic_information(); + } + + virtual + char const * + diagnostic_information() const throw() + { + return _diagnostic_information(0); } protected: @@ -75,6 +72,22 @@ boost { } + char const * + _diagnostic_information( char const * std_what ) const throw() + { + if( data_ ) + try + { + char const * w = data_->diagnostic_information(std_what,typeid(*this)); + BOOST_ASSERT(0!=w); + return w; + } + catch(...) + { + } + return std_what ? std_what : typeid(*this).name(); + } + #if BOOST_WORKAROUND( BOOST_MSVC, BOOST_TESTED_AT(1500) ) //Force class exception to be abstract. //Otherwise, MSVC bug allows throw exception(), even though the copy constructor is protected. From 9064e24a58316f7f1f0cd6a8473e6abb800905b1 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Mon, 30 Jun 2008 19:40:44 +0000 Subject: [PATCH 021/101] Removed boost::exception::what, to avoid ambiguity in user types deriving from both std::exception and boost::exception. [SVN r46930] --- include/boost/exception/exception.hpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index c8a7e72..d128cd3 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -47,13 +47,6 @@ boost { public: - virtual - char const * - what() const throw() - { - return diagnostic_information(); - } - virtual char const * diagnostic_information() const throw() From 86cac42ffda67d59fddcf0807d0628381fc148df Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Wed, 2 Jul 2008 21:50:29 +0000 Subject: [PATCH 022/101] BOOST_NO_TYPEID [SVN r47007] --- include/boost/throw_exception.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/boost/throw_exception.hpp b/include/boost/throw_exception.hpp index 6555763..dc468f2 100644 --- a/include/boost/throw_exception.hpp +++ b/include/boost/throw_exception.hpp @@ -24,6 +24,10 @@ #include #include +#if !defined( BOOST_EXCEPTION_DISABLE ) && defined( BOOST_NO_TYPEID ) +# define BOOST_EXCEPTION_DISABLE +#endif + #if !defined( BOOST_EXCEPTION_DISABLE ) && defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, < 0x590 ) # define BOOST_EXCEPTION_DISABLE #endif From 3ccf93437655a6189999b2abe9b67063df566800 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Wed, 9 Jul 2008 00:18:09 +0000 Subject: [PATCH 023/101] removed tabs from source files updated documentation [SVN r47250] --- doc/throw_exception.html | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/doc/throw_exception.html b/doc/throw_exception.html index 853c8aa..63861ab 100644 --- a/doc/throw_exception.html +++ b/doc/throw_exception.html @@ -19,7 +19,8 @@ -

throw_exception

+

throw_exception

+

#include <boost/throw_exception.hpp>

namespace
 boost
@@ -39,14 +40,16 @@ boost
 

E must derive publicly from std::exception.

Effects:

  • If BOOST_NO_EXCEPTIONS is not defined, boost::throw_exception(e) is equivalent to throw boost::enable_current_exception(boost::enable_error_info(e)), unless BOOST_EXCEPTION_DISABLE is defined, in which case boost::throw_exception(e) is equivalent to throw e;
  • -
  • If BOOST_NO_EXCEPTIONS is defined, the function is left undefined, and the user is expected to supply an appropriate definition. Callers of throw_exception are allowed to assume that the function never returns; therefore, if the user-defined throw_exception returns, the behavior is undefined.
  • +
  • If BOOST_NO_EXCEPTIONS is defined, the function is left undefined, and the user is expected to supply an appropriate definition. Callers of throw_exception are allowed to assume that the function never returns; therefore, if the user-defined throw_exception returns, the behavior is undefined.
-

See also:

+
From 0a453027918afd453c44c82960552125945ac9c9 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Wed, 16 Jul 2008 21:00:44 +0000 Subject: [PATCH 024/101] minor documentation update [SVN r47492] --- doc/throw_exception.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/throw_exception.html b/doc/throw_exception.html index 63861ab..27e7b17 100644 --- a/doc/throw_exception.html +++ b/doc/throw_exception.html @@ -47,7 +47,7 @@ boost
From 512ad21a541537f763bf1eb0adc212450ebf495b Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Wed, 20 Aug 2008 21:48:35 +0000 Subject: [PATCH 025/101] fix for mutable problem, thanks Peter Klotz [SVN r48270] --- include/boost/exception/exception.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index d128cd3..4670481 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -105,7 +105,7 @@ boost template friend shared_ptr get_error_info( E const & ); - intrusive_ptr mutable data_; + mutable intrusive_ptr data_; }; #if BOOST_WORKAROUND( BOOST_MSVC, BOOST_TESTED_AT(1500) ) //See above. From c857f3b36da32c91a66ed2ca0702d8af8d39547e Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Thu, 28 Aug 2008 23:49:55 +0000 Subject: [PATCH 026/101] Boost Exception now works with BOOST_NO_RTTI and/or BOOST_NO_TYPEID. [SVN r48429] --- include/boost/exception/exception.hpp | 50 +++++++++++++++------------ include/boost/throw_exception.hpp | 4 +-- 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index 4670481..8ea1d7e 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -6,7 +6,7 @@ #ifndef UUID_274DA366004E11DCB1DDFE2E56D89593 #define UUID_274DA366004E11DCB1DDFE2E56D89593 -#include +#include #include #include #include @@ -15,6 +15,8 @@ namespace boost { + class exception; + template class shared_ptr; @@ -27,21 +29,17 @@ boost error_info_container: public exception_detail::counted_base { - virtual char const * diagnostic_information( char const *, std::type_info const & ) const = 0; - virtual shared_ptr get( std::type_info const & ) const = 0; - virtual void set( shared_ptr const & ) = 0; + virtual char const * diagnostic_information( char const *, char const * ) const = 0; + virtual shared_ptr get( type_info_ const & ) const = 0; + virtual void set( shared_ptr const &, type_info_ const & ) = 0; }; + + template + shared_ptr get_data( exception const & ); + + void set_data( exception const *, shared_ptr const &, exception_detail::type_info_ const & ); } - template - class error_info; - - template - E const & operator<<( E const &, error_info const & ); - - template - shared_ptr get_error_info( E const & ); - class exception { @@ -71,14 +69,14 @@ boost if( data_ ) try { - char const * w = data_->diagnostic_information(std_what,typeid(*this)); - BOOST_ASSERT(0!=w); + char const * w = data_->diagnostic_information(std_what,dynamic_type_name()); + BOOST_ASSERT(w!=0); return w; } catch(...) { } - return std_what ? std_what : typeid(*this).name(); + return std_what ? std_what : dynamic_type_name(); } #if BOOST_WORKAROUND( BOOST_MSVC, BOOST_TESTED_AT(1500) ) @@ -96,14 +94,22 @@ boost private: - shared_ptr get( std::type_info const & ) const; - void set( shared_ptr const & ) const; + friend void exception_detail::set_data( exception const *, shared_ptr const &, exception_detail::type_info_ const & ); - template - friend E const & operator<<( E const &, error_info const & ); + template + friend shared_ptr exception_detail::get_data( exception const & ); - template - friend shared_ptr get_error_info( E const & ); + char const * + dynamic_type_name() const + { + return +#if defined(BOOST_NO_RTTI) || defined(BOOST_NO_TYPEID) + "Unknown type deriving from boost::exception" +#else + typeid(*this).name() +#endif + ; + } mutable intrusive_ptr data_; }; diff --git a/include/boost/throw_exception.hpp b/include/boost/throw_exception.hpp index dc468f2..ae5ea5a 100644 --- a/include/boost/throw_exception.hpp +++ b/include/boost/throw_exception.hpp @@ -24,8 +24,8 @@ #include #include -#if !defined( BOOST_EXCEPTION_DISABLE ) && defined( BOOST_NO_TYPEID ) -# define BOOST_EXCEPTION_DISABLE +#if !defined( BOOST_EXCEPTION_DISABLE ) +#define BOOST_EXCEPTION_DISABLE #endif #if !defined( BOOST_EXCEPTION_DISABLE ) && defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, < 0x590 ) From 95b0ce06a5e19e945bbe1d8a4ec482da3896f10b Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Sat, 30 Aug 2008 02:57:12 +0000 Subject: [PATCH 027/101] decoupled boost/exception/exception.hpp from boost/exception/detail/type_info.hpp diagnostic_information improvements documentation update [SVN r48469] --- include/boost/exception/exception.hpp | 54 ++++++++++----------------- 1 file changed, 20 insertions(+), 34 deletions(-) diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index 8ea1d7e..b3a754d 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -6,11 +6,8 @@ #ifndef UUID_274DA366004E11DCB1DDFE2E56D89593 #define UUID_274DA366004E11DCB1DDFE2E56D89593 -#include -#include #include #include -#include namespace boost @@ -24,12 +21,13 @@ boost exception_detail { class error_info_base; + struct type_info_; struct error_info_container: public exception_detail::counted_base { - virtual char const * diagnostic_information( char const *, char const * ) const = 0; + virtual char const * diagnostic_information() const = 0; virtual shared_ptr get( type_info_ const & ) const = 0; virtual void set( shared_ptr const &, type_info_ const & ) = 0; }; @@ -37,7 +35,7 @@ boost template shared_ptr get_data( exception const & ); - void set_data( exception const *, shared_ptr const &, exception_detail::type_info_ const & ); + void set_data( exception const *, shared_ptr const &, type_info_ const & ); } class @@ -49,7 +47,7 @@ boost char const * diagnostic_information() const throw() { - return _diagnostic_information(0); + return _diagnostic_information(); } protected: @@ -63,22 +61,6 @@ boost { } - char const * - _diagnostic_information( char const * std_what ) const throw() - { - if( data_ ) - try - { - char const * w = data_->diagnostic_information(std_what,dynamic_type_name()); - BOOST_ASSERT(w!=0); - return w; - } - catch(...) - { - } - return std_what ? std_what : dynamic_type_name(); - } - #if BOOST_WORKAROUND( BOOST_MSVC, BOOST_TESTED_AT(1500) ) //Force class exception to be abstract. //Otherwise, MSVC bug allows throw exception(), even though the copy constructor is protected. @@ -92,6 +74,22 @@ boost } #endif + char const * + _diagnostic_information() const throw() + { + if( data_ ) + try + { + char const * w = data_->diagnostic_information(); + BOOST_ASSERT(w!=0); + return w; + } + catch(...) + { + } + return ""; + } + private: friend void exception_detail::set_data( exception const *, shared_ptr const &, exception_detail::type_info_ const & ); @@ -99,18 +97,6 @@ boost template friend shared_ptr exception_detail::get_data( exception const & ); - char const * - dynamic_type_name() const - { - return -#if defined(BOOST_NO_RTTI) || defined(BOOST_NO_TYPEID) - "Unknown type deriving from boost::exception" -#else - typeid(*this).name() -#endif - ; - } - mutable intrusive_ptr data_; }; From ef9efac658385913acfdac35ec29b4bc6273d3ab Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Sun, 31 Aug 2008 01:39:00 +0000 Subject: [PATCH 028/101] Both enable_error_info.hpp and enable_current_exception.hpp now do not depend on intrusive_ptr or any other Boost lib. [SVN r48482] --- include/boost/exception/exception.hpp | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index b3a754d..5a15480 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -7,7 +7,7 @@ #define UUID_274DA366004E11DCB1DDFE2E56D89593 #include -#include +#include namespace boost @@ -61,28 +61,16 @@ boost { } -#if BOOST_WORKAROUND( BOOST_MSVC, BOOST_TESTED_AT(1500) ) - //Force class exception to be abstract. - //Otherwise, MSVC bug allows throw exception(), even though the copy constructor is protected. virtual ~exception() throw()=0; -#else -#if BOOST_WORKAROUND( __GNUC__, BOOST_TESTED_AT(4) ) - virtual //Disable bogus GCC warning. -#endif - ~exception() throw() - { - } -#endif char const * _diagnostic_information() const throw() { - if( data_ ) + if( exception_detail::error_info_container * c=data_.get() ) try { - char const * w = data_->diagnostic_information(); - BOOST_ASSERT(w!=0); - return w; + if( char const * w = c->diagnostic_information() ) + return w; } catch(...) { @@ -97,16 +85,14 @@ boost template friend shared_ptr exception_detail::get_data( exception const & ); - mutable intrusive_ptr data_; + mutable exception_detail::refcount_ptr data_; }; -#if BOOST_WORKAROUND( BOOST_MSVC, BOOST_TESTED_AT(1500) ) //See above. inline exception:: ~exception() throw() { } -#endif } #endif From 86ad5820a652b93164b202aaf8144318b86838d0 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Sun, 31 Aug 2008 01:58:48 +0000 Subject: [PATCH 029/101] removed explicit copy ctor in boost::exception [SVN r48483] --- include/boost/exception/exception.hpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index 5a15480..645d237 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -14,7 +14,7 @@ boost { class exception; - template + template class shared_ptr; namespace @@ -56,11 +56,6 @@ boost { } - exception( exception const & e ): - data_(e.data_) - { - } - virtual ~exception() throw()=0; char const * @@ -80,11 +75,11 @@ boost private: - friend void exception_detail::set_data( exception const *, shared_ptr const &, exception_detail::type_info_ const & ); - template friend shared_ptr exception_detail::get_data( exception const & ); + friend void exception_detail::set_data( exception const *, shared_ptr const &, exception_detail::type_info_ const & ); + mutable exception_detail::refcount_ptr data_; }; From 2718e529181515b273b2214635c09f35e5ba4ad0 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Sun, 31 Aug 2008 02:40:42 +0000 Subject: [PATCH 030/101] simplified further [SVN r48485] --- include/boost/exception/exception.hpp | 250 +++++++++++++++++++++++++- include/boost/throw_exception.hpp | 3 +- 2 files changed, 248 insertions(+), 5 deletions(-) diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index 645d237..3e7cf27 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -6,12 +6,114 @@ #ifndef UUID_274DA366004E11DCB1DDFE2E56D89593 #define UUID_274DA366004E11DCB1DDFE2E56D89593 -#include -#include - namespace boost { + + //////////////////////////////////////////////////////////////////////// + + namespace + exception_detail + { + template + class + refcount_ptr + { + public: + + refcount_ptr(): + px_(0) + { + } + + ~refcount_ptr() + { + release(); + } + + refcount_ptr( refcount_ptr const & x ): + px_(x.px_) + { + add_ref(); + } + + refcount_ptr & + operator=( refcount_ptr const & x ) + { + adopt(x.px_); + return *this; + } + + void + adopt( T * px ) + { + release(); + px_=px; + add_ref(); + } + + T * + get() const + { + return px_; + } + + private: + + T * px_; + + void + add_ref() + { + if( px_ ) + intrusive_ptr_add_ref(px_); + } + + void + release() + { + if( px_ ) + intrusive_ptr_release(px_); + } + }; + } + + //////////////////////////////////////////////////////////////////////// + + namespace + exception_detail + { + class + counted_base + { + friend + void + intrusive_ptr_add_ref( counted_base const * c ) + { + c->add_ref(); + } + + friend + void + intrusive_ptr_release( counted_base const * c ) + { + c->release(); + } + + virtual void add_ref() const=0; + virtual void release() const=0; + + protected: + + virtual + ~counted_base() throw() + { + } + }; + } + + //////////////////////////////////////////////////////////////////////// + class exception; template @@ -88,6 +190,148 @@ boost ~exception() throw() { } + + //////////////////////////////////////////////////////////////////////// + + namespace + exception_detail + { + template + struct + error_info_injector: + public T, + public exception + { + explicit + error_info_injector( T const & x ): + T(x) + { + } + + ~error_info_injector() throw() + { + } + }; + + struct large_size { char c[256]; }; + large_size dispatch( exception * ); + + struct small_size { }; + small_size dispatch( void * ); + + template + struct enable_error_info_helper; + + template + struct + enable_error_info_helper + { + typedef T type; + }; + + template + struct + enable_error_info_helper + { + typedef error_info_injector type; + }; + + template + struct + enable_error_info_return_type + { + typedef typename enable_error_info_helper::type type; + }; + } + + template + inline + typename + exception_detail::enable_error_info_return_type::type + enable_error_info( T const & x ) + { + return typename exception_detail::enable_error_info_return_type::type(x); + } + + //////////////////////////////////////////////////////////////////////// + + namespace + exception_detail + { + class + clone_base + { + public: + + virtual clone_base const * clone() const = 0; + virtual void rethrow() const = 0; + virtual ~clone_base() throw() = 0; + }; + + inline + clone_base:: + ~clone_base() throw() + { + } + + inline + void + copy_boost_exception( exception * a, exception const * b ) + { + *a = *b; + } + + inline + void + copy_boost_exception( void *, void const * ) + { + } + + template + class + clone_impl: + public T, + public clone_base + { + public: + + explicit + clone_impl( T const & x ): + T(x) + { + copy_boost_exception(this,&x); + } + + ~clone_impl() throw() + { + } + + private: + + clone_base const * + clone() const + { + return new clone_impl(*this); + } + + void + rethrow() const + { + throw *this; + } + }; + } + + template + inline + exception_detail::clone_impl + enable_current_exception( T const & x ) + { + return exception_detail::clone_impl(x); + } + + //////////////////////////////////////////////////////////////////////// + } #endif diff --git a/include/boost/throw_exception.hpp b/include/boost/throw_exception.hpp index ae5ea5a..0834e9d 100644 --- a/include/boost/throw_exception.hpp +++ b/include/boost/throw_exception.hpp @@ -37,8 +37,7 @@ #endif #if !defined( BOOST_NO_EXCEPTIONS ) && !defined( BOOST_EXCEPTION_DISABLE ) -# include -# include +# include #endif namespace boost From 67d235059a831f5d0e281bd97c3960be6bcae33a Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Sun, 31 Aug 2008 04:05:19 +0000 Subject: [PATCH 031/101] nitpicking [SVN r48488] --- include/boost/exception/exception.hpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index 3e7cf27..dcc6d43 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -119,6 +119,12 @@ boost template class shared_ptr; + template + class error_info; + + template + E const & operator<<( E const &, error_info const & ); + namespace exception_detail { @@ -135,9 +141,7 @@ boost }; template - shared_ptr get_data( exception const & ); - - void set_data( exception const *, shared_ptr const &, type_info_ const & ); + shared_ptr get_info( exception const & ); } class @@ -177,10 +181,11 @@ boost private: - template - friend shared_ptr exception_detail::get_data( exception const & ); + template + friend E const & operator<<( E const &, error_info const & ); - friend void exception_detail::set_data( exception const *, shared_ptr const &, exception_detail::type_info_ const & ); + template + friend shared_ptr exception_detail::get_info( exception const & ); mutable exception_detail::refcount_ptr data_; }; From 019fbaa77e35e1aa020f2e25a3dd4a71e8767beb Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Mon, 1 Sep 2008 21:06:09 +0000 Subject: [PATCH 032/101] Optimization for error_info, error_info, error_info. Refactored exception_ptr to use shared_ptr. [SVN r48521] --- include/boost/exception/exception.hpp | 193 +++++++++++++++----------- include/boost/throw_exception.hpp | 7 + 2 files changed, 116 insertions(+), 84 deletions(-) diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index dcc6d43..5cba804 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -9,9 +9,6 @@ namespace boost { - - //////////////////////////////////////////////////////////////////////// - namespace exception_detail { @@ -66,65 +63,77 @@ boost add_ref() { if( px_ ) - intrusive_ptr_add_ref(px_); + px_->add_ref(); } void release() { if( px_ ) - intrusive_ptr_release(px_); + px_->release(); } }; } //////////////////////////////////////////////////////////////////////// - namespace - exception_detail + template + class error_info; + + typedef error_info throw_function; + typedef error_info throw_file; + typedef error_info throw_line; + + template <> + class + error_info { - class - counted_base + public: + typedef char const * value_type; + value_type v_; + explicit + error_info( value_type v ): + v_(v) { - friend - void - intrusive_ptr_add_ref( counted_base const * c ) - { - c->add_ref(); - } + } + }; - friend - void - intrusive_ptr_release( counted_base const * c ) - { - c->release(); - } + template <> + class + error_info + { + public: + typedef char const * value_type; + value_type v_; + explicit + error_info( value_type v ): + v_(v) + { + } + }; - virtual void add_ref() const=0; - virtual void release() const=0; + template <> + class + error_info + { + public: + typedef int value_type; + value_type v_; + explicit + error_info( value_type v ): + v_(v) + { + } + }; - protected: - - virtual - ~counted_base() throw() - { - } - }; - } - - //////////////////////////////////////////////////////////////////////// + template + E const & operator<<( E const &, error_info const & ); class exception; template class shared_ptr; - template - class error_info; - - template - E const & operator<<( E const &, error_info const & ); - namespace exception_detail { @@ -132,62 +141,83 @@ boost struct type_info_; struct - error_info_container: - public exception_detail::counted_base + error_info_container { virtual char const * diagnostic_information() const = 0; virtual shared_ptr get( type_info_ const & ) const = 0; virtual void set( shared_ptr const &, type_info_ const & ) = 0; + virtual void add_ref() const = 0; + virtual void release() const = 0; + + protected: + + virtual + ~error_info_container() throw() + { + } }; - template - shared_ptr get_info( exception const & ); + template + struct get_info; + + char const * get_diagnostic_information( exception const & ); } class exception { - public: - - virtual - char const * - diagnostic_information() const throw() - { - return _diagnostic_information(); - } - protected: - exception() + exception(): + throw_function_(0), + throw_file_(0), + throw_line_(-1) { } - virtual ~exception() throw()=0; - - char const * - _diagnostic_information() const throw() - { - if( exception_detail::error_info_container * c=data_.get() ) - try - { - if( char const * w = c->diagnostic_information() ) - return w; - } - catch(...) - { - } - return ""; - } + virtual ~exception() throw() = 0; private: - template - friend E const & operator<<( E const &, error_info const & ); + template + friend + E const & + operator<<( E const & x, throw_function y ) + { + x.throw_function_=y.v_; + return x; + } - template - friend shared_ptr exception_detail::get_info( exception const & ); + template + friend + E const & + operator<<( E const & x, throw_file y ) + { + x.throw_file_=y.v_; + return x; + } + + template + friend + E const & + operator<<( E const & x, throw_line y ) + { + x.throw_line_=y.v_; + return x; + } + + friend char const * exception_detail::get_diagnostic_information( exception const & ); + + template + friend E const & operator<<( E const &, error_info const & ); + + template + friend struct exception_detail::get_info; mutable exception_detail::refcount_ptr data_; + mutable char const * throw_function_; + mutable char const * throw_file_; + mutable int throw_line_; }; inline @@ -270,14 +300,12 @@ boost virtual clone_base const * clone() const = 0; virtual void rethrow() const = 0; - virtual ~clone_base() throw() = 0; - }; - inline - clone_base:: - ~clone_base() throw() - { - } + virtual + ~clone_base() throw() + { + } + }; inline void @@ -322,7 +350,7 @@ boost void rethrow() const { - throw *this; + throw*this; } }; } @@ -334,9 +362,6 @@ boost { return exception_detail::clone_impl(x); } - - //////////////////////////////////////////////////////////////////////// - } #endif diff --git a/include/boost/throw_exception.hpp b/include/boost/throw_exception.hpp index 0834e9d..94536d3 100644 --- a/include/boost/throw_exception.hpp +++ b/include/boost/throw_exception.hpp @@ -38,6 +38,13 @@ #if !defined( BOOST_NO_EXCEPTIONS ) && !defined( BOOST_EXCEPTION_DISABLE ) # include +# include +# define BOOST_THROW_EXCEPTION(x) ::boost::throw_exception(::boost::enable_error_info(x) <<\ + ::boost::throw_function(BOOST_CURRENT_FUNCTION) <<\ + ::boost::throw_file(__FILE__) <<\ + ::boost::throw_line((int)__LINE__)) +#else +# define BOOST_THROW_EXCEPTION(x) ::boost::throw_exception(x) #endif namespace boost From db6110057ad7531caeade8e6a2ae9562cfe53a0e Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Tue, 2 Sep 2008 17:47:51 +0000 Subject: [PATCH 033/101] fix for sun compilers and documentation source update [SVN r48538] --- include/boost/exception/exception.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index 5cba804..970db8b 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -160,6 +160,15 @@ boost template struct get_info; + template <> + struct get_info; + + template <> + struct get_info; + + template <> + struct get_info; + char const * get_diagnostic_information( exception const & ); } @@ -213,6 +222,9 @@ boost template friend struct exception_detail::get_info; + friend struct exception_detail::get_info; + friend struct exception_detail::get_info; + friend struct exception_detail::get_info; mutable exception_detail::refcount_ptr data_; mutable char const * throw_function_; From 3623b2d32e1c0315f4677b7df9f669d9f53b974e Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Tue, 2 Sep 2008 18:44:05 +0000 Subject: [PATCH 034/101] minor diagnostic_information fix. [SVN r48543] --- include/boost/exception/exception.hpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index 970db8b..fdae86a 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -160,13 +160,13 @@ boost template struct get_info; - template <> + template <> struct get_info; - template <> + template <> struct get_info; - template <> + template <> struct get_info; char const * get_diagnostic_information( exception const & ); @@ -313,10 +313,10 @@ boost virtual clone_base const * clone() const = 0; virtual void rethrow() const = 0; - virtual - ~clone_base() throw() - { - } + virtual + ~clone_base() throw() + { + } }; inline From f3e517598b1bd3c4e72fcde3b8c9a110207b7050 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Tue, 2 Sep 2008 21:02:25 +0000 Subject: [PATCH 035/101] documentation update [SVN r48544] --- doc/throw_exception.html | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/doc/throw_exception.html b/doc/throw_exception.html index 27e7b17..d9eee8f 100644 --- a/doc/throw_exception.html +++ b/doc/throw_exception.html @@ -26,14 +26,10 @@ boost { #ifdef BOOST_NO_EXCEPTIONS - - void throw_exception( std::exception const & e ); // user defined - + void throw_exception( std::exception const & e ); // user defined #else - - template <class E> - void throw_exception( E const & e ); - + template <class E> + void throw_exception( E const & e ); #endif }

Requirements:

@@ -44,7 +40,8 @@ boost

See Also:

-
Boost Exception
+

Requirements:

E must derive publicly from std::exception.

From 0449861f375dc8888e4aafb84bd2e2172ac87348 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Tue, 2 Sep 2008 23:20:49 +0000 Subject: [PATCH 037/101] documentation update [SVN r48554] --- doc/BOOST_THROW_EXCEPTION.html | 57 ++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 doc/BOOST_THROW_EXCEPTION.html diff --git a/doc/BOOST_THROW_EXCEPTION.html b/doc/BOOST_THROW_EXCEPTION.html new file mode 100644 index 0000000..d96f297 --- /dev/null +++ b/doc/BOOST_THROW_EXCEPTION.html @@ -0,0 +1,57 @@ + + + + + BOOST_THROW_EXCEPTION + + + +
+
+
+
+ +

Boost Exception

+
+ + + +

BOOST_THROW_EXCEPTION

+
+

#include <boost/throw_exception.hpp>

+
#if !defined( BOOST_NO_EXCEPTIONS ) && !defined( BOOST_EXCEPTION_DISABLE )
+    #include <boost/exception/exception.hpp>
+    #include <boost/current_function.hpp>
+    #define BOOST_THROW_EXCEPTION(x)\
+        ::boost::throw_exception( ::boost::enable_error_info(x) <<\
+        ::boost::throw_function(BOOST_CURRENT_FUNCTION) <<\
+        ::boost::throw_file(__FILE__) <<\
+        ::boost::throw_line((int)__LINE__) )
+#else
+    #define BOOST_THROW_EXCEPTION(x) ::boost::throw_exception(x)
+#endif
+

This macro takes an exception object, records BOOST_CURRENT_FUNCTION, __FILE__ and __LINE__ in it, and forwards it to throw_exception. To recover this information at the catch site, use get_error_info; the information is also included in the message returned by diagnostic_information.

+
+ + + + +
+
+
+ + From 1c31400c0a2b773d41f73d9a3f70f32af0b308df Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Wed, 3 Sep 2008 19:07:23 +0000 Subject: [PATCH 038/101] documentation update [SVN r48568] --- doc/throw_exception.html | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/throw_exception.html b/doc/throw_exception.html index ab789e9..32229c2 100644 --- a/doc/throw_exception.html +++ b/doc/throw_exception.html @@ -43,6 +43,7 @@ boost From 92d96f1aa4285e621217060cb244f30ec0acf88a Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Sat, 6 Sep 2008 18:40:02 +0000 Subject: [PATCH 039/101] Bug in type_info.hpp [SVN r48634] --- include/boost/throw_exception.hpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/include/boost/throw_exception.hpp b/include/boost/throw_exception.hpp index 94536d3..018eb2a 100644 --- a/include/boost/throw_exception.hpp +++ b/include/boost/throw_exception.hpp @@ -24,10 +24,6 @@ #include #include -#if !defined( BOOST_EXCEPTION_DISABLE ) -#define BOOST_EXCEPTION_DISABLE -#endif - #if !defined( BOOST_EXCEPTION_DISABLE ) && defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, < 0x590 ) # define BOOST_EXCEPTION_DISABLE #endif From 95bdbc8678ac215ac05066f692a72a4acda3c502 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Sat, 6 Sep 2008 19:24:13 +0000 Subject: [PATCH 040/101] documentation update [SVN r48635] --- doc/throw_exception.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/throw_exception.html b/doc/throw_exception.html index 32229c2..f4eb745 100644 --- a/doc/throw_exception.html +++ b/doc/throw_exception.html @@ -43,7 +43,7 @@ boost From 1d72f65bdbe9421f8ac99517cbf59c8351c79819 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Mon, 8 Sep 2008 18:27:24 +0000 Subject: [PATCH 041/101] Hopefully a workaround for an overload resolution bug in Sun compilers causing minor problems [SVN r48668] --- include/boost/exception/exception.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index fdae86a..c6a8fbd 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -191,7 +191,7 @@ boost template friend E const & - operator<<( E const & x, throw_function y ) + operator<<( E const & x, throw_function const & y ) { x.throw_function_=y.v_; return x; @@ -200,7 +200,7 @@ boost template friend E const & - operator<<( E const & x, throw_file y ) + operator<<( E const & x, throw_file const & y ) { x.throw_file_=y.v_; return x; @@ -209,7 +209,7 @@ boost template friend E const & - operator<<( E const & x, throw_line y ) + operator<<( E const & x, throw_line const & y ) { x.throw_line_=y.v_; return x; From a1db718dcc6bfb57c2a67d97326357b7eaa0a78f Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Tue, 9 Sep 2008 23:44:16 +0000 Subject: [PATCH 042/101] Workaround for the HP-UX_ia64_aCC failures. [SVN r48690] --- include/boost/exception/exception.hpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index c6a8fbd..3d5383d 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -184,7 +184,23 @@ boost { } - virtual ~exception() throw() = 0; +#ifdef __HP_aCC + //On HP aCC, this protected copy constructor prevents throwing boost::exception. + //On all other platforms, the same effect is achieved by the pure virtual destructor. + exception( exception const & x ) throw(): + data_(x.data_), + throw_function_(x.throw_function_), + throw_file_(x.throw_file_), + throw_line_(x.throw_line_) + { + } +#endif + + virtual ~exception() throw() +#ifndef __HP_aCC + = 0 //Workaround for HP aCC, =0 incorrectly leads to link errors. +#endif + ; private: From 3729ff1493244ab54adde482227288be4b3414f2 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Thu, 11 Sep 2008 18:15:25 +0000 Subject: [PATCH 043/101] Added 4 more tests [SVN r48738] --- test/1-throw_exception_test.cpp | 29 +++++++++++++++++ test/2-throw_exception_no_exceptions_test.cpp | 30 ++++++++++++++++++ .../3-throw_exception_no_integration_test.cpp | 30 ++++++++++++++++++ test/4-throw_exception_no_both_test.cpp | 31 +++++++++++++++++++ 4 files changed, 120 insertions(+) create mode 100644 test/1-throw_exception_test.cpp create mode 100644 test/2-throw_exception_no_exceptions_test.cpp create mode 100644 test/3-throw_exception_no_integration_test.cpp create mode 100644 test/4-throw_exception_no_both_test.cpp diff --git a/test/1-throw_exception_test.cpp b/test/1-throw_exception_test.cpp new file mode 100644 index 0000000..5719e80 --- /dev/null +++ b/test/1-throw_exception_test.cpp @@ -0,0 +1,29 @@ +//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc. + +//Distributed under the Boost Software License, Version 1.0. (See accompanying +//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#include +#include + +class my_exception: public std::exception { }; + +int +main() + { + try + { + boost::throw_exception(my_exception()); + BOOST_ERROR("boost::throw_exception failed to throw."); + } + catch( + my_exception & ) + { + } + catch( + ... ) + { + BOOST_ERROR("boost::throw_exception malfunction."); + } + return boost::report_errors(); + } diff --git a/test/2-throw_exception_no_exceptions_test.cpp b/test/2-throw_exception_no_exceptions_test.cpp new file mode 100644 index 0000000..aca309d --- /dev/null +++ b/test/2-throw_exception_no_exceptions_test.cpp @@ -0,0 +1,30 @@ +//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc. + +//Distributed under the Boost Software License, Version 1.0. (See accompanying +//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#define BOOST_NO_EXCEPTIONS +#include +#include + +class my_exception: public std::exception { }; + +bool called=false; + +namespace +boost + { + void + throw_exception( std::exception const & ) + { + called=true; + } + } + +int +main() + { + boost::throw_exception(my_exception()); + BOOST_TEST(called); + return boost::report_errors(); + } diff --git a/test/3-throw_exception_no_integration_test.cpp b/test/3-throw_exception_no_integration_test.cpp new file mode 100644 index 0000000..16b3d8c --- /dev/null +++ b/test/3-throw_exception_no_integration_test.cpp @@ -0,0 +1,30 @@ +//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc. + +//Distributed under the Boost Software License, Version 1.0. (See accompanying +//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#define BOOST_EXCEPTION_DISABLE +#include +#include + +class my_exception: public std::exception { }; + +int +main() + { + try + { + boost::throw_exception(my_exception()); + BOOST_ERROR("boost::throw_exception failed to throw."); + } + catch( + my_exception & ) + { + } + catch( + ... ) + { + BOOST_ERROR("boost::throw_exception malfunction."); + } + return boost::report_errors(); + } diff --git a/test/4-throw_exception_no_both_test.cpp b/test/4-throw_exception_no_both_test.cpp new file mode 100644 index 0000000..4c58605 --- /dev/null +++ b/test/4-throw_exception_no_both_test.cpp @@ -0,0 +1,31 @@ +//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc. + +//Distributed under the Boost Software License, Version 1.0. (See accompanying +//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#define BOOST_NO_EXCEPTIONS +#define BOOST_EXCEPTION_DISABLE +#include +#include + +class my_exception: public std::exception { }; + +bool called=false; + +namespace +boost + { + void + throw_exception( std::exception const & ) + { + called=true; + } + } + +int +main() + { + boost::throw_exception(my_exception()); + BOOST_TEST(called); + return boost::report_errors(); + } From 88d9f3ae648296fed99b8cf80b855308eb0ddc01 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Tue, 16 Sep 2008 04:07:43 +0000 Subject: [PATCH 044/101] Hopefully properly disabling boost exception integration in throw_exception.hpp for Borland <= 5.9.3 [SVN r48792] --- include/boost/throw_exception.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/throw_exception.hpp b/include/boost/throw_exception.hpp index 018eb2a..5d00854 100644 --- a/include/boost/throw_exception.hpp +++ b/include/boost/throw_exception.hpp @@ -24,7 +24,7 @@ #include #include -#if !defined( BOOST_EXCEPTION_DISABLE ) && defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, < 0x590 ) +#if !defined( BOOST_EXCEPTION_DISABLE ) && defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, <= 0x593 ) # define BOOST_EXCEPTION_DISABLE #endif From f33d01a7a703ace8fb4314489dfae7ae04e3db0f Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Fri, 19 Sep 2008 00:09:47 +0000 Subject: [PATCH 045/101] #defined BOOST_EXCEPTION_DISABLE on any BCC until workarounds are found for the tests in libs/exception/test. [SVN r48860] --- include/boost/throw_exception.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/throw_exception.hpp b/include/boost/throw_exception.hpp index 5d00854..69cdad0 100644 --- a/include/boost/throw_exception.hpp +++ b/include/boost/throw_exception.hpp @@ -24,7 +24,7 @@ #include #include -#if !defined( BOOST_EXCEPTION_DISABLE ) && defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, <= 0x593 ) +#if !defined( BOOST_EXCEPTION_DISABLE ) && defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x593) ) # define BOOST_EXCEPTION_DISABLE #endif From 97a934102e3819b2bb9b6aeffcc741b97278b366 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Mon, 22 Sep 2008 18:27:58 +0000 Subject: [PATCH 046/101] Improving CodeGear C++Builder 2009 compatibility [SVN r48918] --- include/boost/exception/exception.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index 3d5383d..53e6ed0 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -313,7 +313,8 @@ boost exception_detail::enable_error_info_return_type::type enable_error_info( T const & x ) { - return typename exception_detail::enable_error_info_return_type::type(x); + typedef typename exception_detail::enable_error_info_return_type::type rt; + return rt(x); } //////////////////////////////////////////////////////////////////////// From ffb3c43b3f79269b011d84f2958f9392d7ba1bfd Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Sun, 29 Mar 2009 04:58:33 +0000 Subject: [PATCH 047/101] documentation update [SVN r52046] --- doc/BOOST_THROW_EXCEPTION.html | 2 +- doc/throw_exception.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/BOOST_THROW_EXCEPTION.html b/doc/BOOST_THROW_EXCEPTION.html index d96f297..e74167d 100644 --- a/doc/BOOST_THROW_EXCEPTION.html +++ b/doc/BOOST_THROW_EXCEPTION.html @@ -44,7 +44,7 @@

 


- + Copyright (c) 2006-2008 by Emil Dotchevski and Reverge Studios, Inc.
Distributed under the Boost Software License, Version 1.0.
diff --git a/doc/throw_exception.html b/doc/throw_exception.html index f4eb745..0a33e20 100644 --- a/doc/throw_exception.html +++ b/doc/throw_exception.html @@ -55,7 +55,7 @@ boost

 


- + Copyright (c) 2006-2008 by Emil Dotchevski and Reverge Studios, Inc.
Distributed under the Boost Software License, Version 1.0.
From 1a97011caca64ba384579a7bcdf628994746e8c0 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Wed, 1 Apr 2009 21:31:03 +0000 Subject: [PATCH 048/101] Documentation update [SVN r52122] --- doc/BOOST_THROW_EXCEPTION.html | 1 + doc/throw_exception.html | 1 + 2 files changed, 2 insertions(+) diff --git a/doc/BOOST_THROW_EXCEPTION.html b/doc/BOOST_THROW_EXCEPTION.html index e74167d..6df9a59 100644 --- a/doc/BOOST_THROW_EXCEPTION.html +++ b/doc/BOOST_THROW_EXCEPTION.html @@ -36,6 +36,7 @@

This macro takes an exception object, records BOOST_CURRENT_FUNCTION, __FILE__ and __LINE__ in it, and forwards it to throw_exception. To recover this information at the catch site, use get_error_info; the information is also included in the message returned by diagnostic_information.

diff --git a/doc/throw_exception.html b/doc/throw_exception.html index 0a33e20..4d3b9c2 100644 --- a/doc/throw_exception.html +++ b/doc/throw_exception.html @@ -45,6 +45,7 @@ boost boost/throw_exception.hpp
Configuration Macros
enable_current_exception
+
Frequently Asked Questions
Transporting of Exceptions Between Threads
From 9ff6182f155d8d94970990d73b9261e810f1dc20 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Thu, 2 Apr 2009 05:00:47 +0000 Subject: [PATCH 049/101] documentation copyright message update [SVN r52125] --- doc/BOOST_THROW_EXCEPTION.html | 6 +++--- doc/throw_exception.html | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/BOOST_THROW_EXCEPTION.html b/doc/BOOST_THROW_EXCEPTION.html index 6df9a59..d56d97e 100644 --- a/doc/BOOST_THROW_EXCEPTION.html +++ b/doc/BOOST_THROW_EXCEPTION.html @@ -16,7 +16,7 @@

Boost Exception

- +

BOOST_THROW_EXCEPTION

@@ -38,7 +38,7 @@ boost/throw_exception.hpp
Frequently Asked Questions
- + diff --git a/doc/throw_exception.html b/doc/throw_exception.html index 4d3b9c2..70236df 100644 --- a/doc/throw_exception.html +++ b/doc/throw_exception.html @@ -16,7 +16,7 @@

Boost Exception

- +

throw_exception

@@ -49,7 +49,7 @@ boost Transporting of Exceptions Between Threads
- + From 167bdd0748d4657eb9d6296cbc320db63126dce7 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Mon, 6 Apr 2009 23:15:42 +0000 Subject: [PATCH 050/101] get_error_info returns raw pointer instead of shared_ptr (breaking change) diagnostic_information can now be called with boost::exception or std::exception object. BOOST_THROW_EXCEPTION can now be used even if exceptions are disabled. added functions: current_exception_diagnostic_information, current_exception_cast documentation updated to match. [SVN r52225] --- doc/BOOST_THROW_EXCEPTION.html | 7 +++++-- include/boost/throw_exception.hpp | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/doc/BOOST_THROW_EXCEPTION.html b/doc/BOOST_THROW_EXCEPTION.html index d56d97e..bf355d7 100644 --- a/doc/BOOST_THROW_EXCEPTION.html +++ b/doc/BOOST_THROW_EXCEPTION.html @@ -22,7 +22,7 @@

BOOST_THROW_EXCEPTION

#include <boost/throw_exception.hpp>

-
#if !defined( BOOST_NO_EXCEPTIONS ) && !defined( BOOST_EXCEPTION_DISABLE )
+
#if !defined( BOOST_EXCEPTION_DISABLE )
     #include <boost/exception/exception.hpp>
     #include <boost/current_function.hpp>
     #define BOOST_THROW_EXCEPTION(x)\
@@ -34,10 +34,13 @@
     #define BOOST_THROW_EXCEPTION(x) ::boost::throw_exception(x)
 #endif

This macro takes an exception object, records BOOST_CURRENT_FUNCTION, __FILE__ and __LINE__ in it, and forwards it to throw_exception. To recover this information at the catch site, use get_error_info; the information is also included in the message returned by diagnostic_information.

-
diff --git a/include/boost/throw_exception.hpp b/include/boost/throw_exception.hpp index 69cdad0..ed03335 100644 --- a/include/boost/throw_exception.hpp +++ b/include/boost/throw_exception.hpp @@ -32,7 +32,7 @@ # define BOOST_EXCEPTION_DISABLE #endif -#if !defined( BOOST_NO_EXCEPTIONS ) && !defined( BOOST_EXCEPTION_DISABLE ) +#if !defined( BOOST_EXCEPTION_DISABLE ) # include # include # define BOOST_THROW_EXCEPTION(x) ::boost::throw_exception(::boost::enable_error_info(x) <<\ From c9c7d509d0a1ec6422b6cea8d1005c16af702723 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Tue, 7 Apr 2009 03:02:15 +0000 Subject: [PATCH 051/101] comments [SVN r52227] --- include/boost/exception/exception.hpp | 2 +- include/boost/throw_exception.hpp | 2 +- test/1-throw_exception_test.cpp | 2 +- test/2-throw_exception_no_exceptions_test.cpp | 2 +- test/3-throw_exception_no_integration_test.cpp | 2 +- test/4-throw_exception_no_both_test.cpp | 2 +- test/throw_exception_fail.cpp | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index 53e6ed0..6df93ac 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -1,4 +1,4 @@ -//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc. +//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc. //Distributed under the Boost Software License, Version 1.0. (See accompanying //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/boost/throw_exception.hpp b/include/boost/throw_exception.hpp index ed03335..da14339 100644 --- a/include/boost/throw_exception.hpp +++ b/include/boost/throw_exception.hpp @@ -11,7 +11,7 @@ // boost/throw_exception.hpp // // Copyright (c) 2002 Peter Dimov and Multi Media Ltd. -// Copyright (c) 2008 Emil Dotchevski and Reverge Studios, Inc. +// Copyright (c) 2008-2009 Emil Dotchevski and Reverge Studios, Inc. // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at diff --git a/test/1-throw_exception_test.cpp b/test/1-throw_exception_test.cpp index 5719e80..06273bc 100644 --- a/test/1-throw_exception_test.cpp +++ b/test/1-throw_exception_test.cpp @@ -1,4 +1,4 @@ -//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc. +//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc. //Distributed under the Boost Software License, Version 1.0. (See accompanying //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/2-throw_exception_no_exceptions_test.cpp b/test/2-throw_exception_no_exceptions_test.cpp index aca309d..91b84b7 100644 --- a/test/2-throw_exception_no_exceptions_test.cpp +++ b/test/2-throw_exception_no_exceptions_test.cpp @@ -1,4 +1,4 @@ -//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc. +//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc. //Distributed under the Boost Software License, Version 1.0. (See accompanying //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/3-throw_exception_no_integration_test.cpp b/test/3-throw_exception_no_integration_test.cpp index 16b3d8c..6fa78f5 100644 --- a/test/3-throw_exception_no_integration_test.cpp +++ b/test/3-throw_exception_no_integration_test.cpp @@ -1,4 +1,4 @@ -//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc. +//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc. //Distributed under the Boost Software License, Version 1.0. (See accompanying //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/4-throw_exception_no_both_test.cpp b/test/4-throw_exception_no_both_test.cpp index 4c58605..789bb74 100644 --- a/test/4-throw_exception_no_both_test.cpp +++ b/test/4-throw_exception_no_both_test.cpp @@ -1,4 +1,4 @@ -//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc. +//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc. //Distributed under the Boost Software License, Version 1.0. (See accompanying //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/throw_exception_fail.cpp b/test/throw_exception_fail.cpp index 19fda91..9f34104 100644 --- a/test/throw_exception_fail.cpp +++ b/test/throw_exception_fail.cpp @@ -1,4 +1,4 @@ -//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc. +//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc. //Distributed under the Boost Software License, Version 1.0. (See accompanying //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) From bd0f8dbfded1665483ea8342b8f12c5f2fb76726 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Wed, 8 Apr 2009 20:08:44 +0000 Subject: [PATCH 052/101] Documentation update [SVN r52265] --- doc/BOOST_THROW_EXCEPTION.html | 4 ++-- doc/throw_exception.html | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/BOOST_THROW_EXCEPTION.html b/doc/BOOST_THROW_EXCEPTION.html index bf355d7..255b8e2 100644 --- a/doc/BOOST_THROW_EXCEPTION.html +++ b/doc/BOOST_THROW_EXCEPTION.html @@ -25,13 +25,13 @@
#if !defined( BOOST_EXCEPTION_DISABLE )
     #include <boost/exception/exception.hpp>
     #include <boost/current_function.hpp>
-    #define BOOST_THROW_EXCEPTION(x)\
+    #define BOOST_THROW_EXCEPTION(x)\
         ::boost::throw_exception( ::boost::enable_error_info(x) <<\
         ::boost::throw_function(BOOST_CURRENT_FUNCTION) <<\
         ::boost::throw_file(__FILE__) <<\
         ::boost::throw_line((int)__LINE__) )
 #else
-    #define BOOST_THROW_EXCEPTION(x) ::boost::throw_exception(x)
+    #define BOOST_THROW_EXCEPTION(x) ::boost::throw_exception(x)
 #endif

This macro takes an exception object, records BOOST_CURRENT_FUNCTION, __FILE__ and __LINE__ in it, and forwards it to throw_exception. To recover this information at the catch site, use get_error_info; the information is also included in the message returned by diagnostic_information.


diff --git a/doc/throw_exception.html b/doc/throw_exception.html index 70236df..cf4ef4b 100644 --- a/doc/throw_exception.html +++ b/doc/throw_exception.html @@ -26,17 +26,17 @@ boost { #ifdef BOOST_NO_EXCEPTIONS - void throw_exception( std::exception const & e ); // user defined + void throw_exception( std::exception const & e ); // user defined #else template <class E> - void throw_exception( E const & e ); + void throw_exception( E const & e ); #endif }

Requirements:

E must derive publicly from std::exception.

Effects:

-
  • If BOOST_NO_EXCEPTIONS is not defined, boost::throw_exception(e) is equivalent to throw boost::enable_current_exception(boost::enable_error_info(e)), unless BOOST_EXCEPTION_DISABLE is defined, in which case boost::throw_exception(e) is equivalent to throw e;
  • -
  • If BOOST_NO_EXCEPTIONS is defined, the function is left undefined, and the user is expected to supply an appropriate definition. Callers of throw_exception are allowed to assume that the function never returns; therefore, if the user-defined throw_exception returns, the behavior is undefined.
  • +
    • If BOOST_NO_EXCEPTIONS is not defined, boost::throw_exception(e) is equivalent to throw boost::enable_current_exception(boost::enable_error_info(e)), unless BOOST_EXCEPTION_DISABLE is defined, in which case boost::throw_exception(e) is equivalent to throw e;
    • +
    • If BOOST_NO_EXCEPTIONS is defined, the function is left undefined, and the user is expected to supply an appropriate definition. Callers of throw_exception are allowed to assume that the function never returns; therefore, if the user-defined throw_exception returns, the behavior is undefined.

See Also:

From 12b5fa85d04e851b51293299dae74deb16da737c Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Wed, 8 Apr 2009 20:23:27 +0000 Subject: [PATCH 053/101] Documentation update [SVN r52267] --- doc/throw_exception.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/throw_exception.html b/doc/throw_exception.html index cf4ef4b..475af83 100644 --- a/doc/throw_exception.html +++ b/doc/throw_exception.html @@ -38,6 +38,8 @@ boost
  • If BOOST_NO_EXCEPTIONS is not defined, boost::throw_exception(e) is equivalent to throw boost::enable_current_exception(boost::enable_error_info(e)), unless BOOST_EXCEPTION_DISABLE is defined, in which case boost::throw_exception(e) is equivalent to throw e;
  • If BOOST_NO_EXCEPTIONS is defined, the function is left undefined, and the user is expected to supply an appropriate definition. Callers of throw_exception are allowed to assume that the function never returns; therefore, if the user-defined throw_exception returns, the behavior is undefined.
+

Note:

+

Under BOOST_NO_EXCEPTIONS, unless BOOST_EXCEPTION_DISABLE is also defined, users can examine the passed exception object using boost::get_error_info, or format an automatic diagnostic message using boost::diagnostic_information.


See Also:

BOOST_THROW_EXCEPTION
From d73c7cffef38d5405ca6cf34f60257ad8facb647 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Wed, 29 Apr 2009 21:19:12 +0000 Subject: [PATCH 054/101] Use local copies of the boost logo. [SVN r52666] --- doc/BOOST_THROW_EXCEPTION.html | 2 +- doc/throw_exception.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/BOOST_THROW_EXCEPTION.html b/doc/BOOST_THROW_EXCEPTION.html index 255b8e2..f25121d 100644 --- a/doc/BOOST_THROW_EXCEPTION.html +++ b/doc/BOOST_THROW_EXCEPTION.html @@ -12,7 +12,7 @@

Boost Exception

diff --git a/doc/throw_exception.html b/doc/throw_exception.html index 475af83..e75c902 100644 --- a/doc/throw_exception.html +++ b/doc/throw_exception.html @@ -12,7 +12,7 @@

Boost Exception

From 7c3618879c3772018c16caa832acbd4aef03a3ed Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Thu, 14 May 2009 00:36:46 +0000 Subject: [PATCH 055/101] exception_ptr improvements, documentation update. [SVN r52981] --- doc/BOOST_THROW_EXCEPTION.html | 12 ++--- doc/boost_throw_exception_hpp.html | 72 ++++++++++++++++++++++++++++++ doc/throw_exception.html | 4 +- 3 files changed, 80 insertions(+), 8 deletions(-) create mode 100644 doc/boost_throw_exception_hpp.html diff --git a/doc/BOOST_THROW_EXCEPTION.html b/doc/BOOST_THROW_EXCEPTION.html index f25121d..9647705 100644 --- a/doc/BOOST_THROW_EXCEPTION.html +++ b/doc/BOOST_THROW_EXCEPTION.html @@ -21,15 +21,15 @@

BOOST_THROW_EXCEPTION

-

#include <boost/throw_exception.hpp>

+

#include <boost/throw_exception.hpp>

#if !defined( BOOST_EXCEPTION_DISABLE )
-    #include <boost/exception/exception.hpp>
+    #include <boost/exception/exception.hpp>
     #include <boost/current_function.hpp>
     #define BOOST_THROW_EXCEPTION(x)\
         ::boost::throw_exception( ::boost::enable_error_info(x) <<\
-        ::boost::throw_function(BOOST_CURRENT_FUNCTION) <<\
-        ::boost::throw_file(__FILE__) <<\
-        ::boost::throw_line((int)__LINE__) )
+        ::boost::throw_function(BOOST_CURRENT_FUNCTION) <<\
+        ::boost::throw_file(__FILE__) <<\
+        ::boost::throw_line((int)__LINE__) )
 #else
     #define BOOST_THROW_EXCEPTION(x) ::boost::throw_exception(x)
 #endif
@@ -37,7 +37,7 @@
diff --git a/doc/boost_throw_exception_hpp.html b/doc/boost_throw_exception_hpp.html new file mode 100644 index 0000000..2ce4c02 --- /dev/null +++ b/doc/boost_throw_exception_hpp.html @@ -0,0 +1,72 @@ + + + + + boost/throw_exception.hpp + + + +
+
+
+
+ +

Boost Exception

+
+ + + +

boost/throw_exception.hpp

+
+

Synopsis

+
#if !defined( BOOST_EXCEPTION_DISABLE )
+    #include <boost/exception/exception.hpp>
+    #include <boost/current_function.hpp>
+    #define BOOST_THROW_EXCEPTION(x)\
+        ::boost::throw_exception( ::boost::enable_error_info(x) <<\
+        ::boost::throw_function(BOOST_CURRENT_FUNCTION) <<\
+        ::boost::throw_file(__FILE__) <<\
+        ::boost::throw_line((int)__LINE__) )
+#else
+    #define BOOST_THROW_EXCEPTION(x) ::boost::throw_exception(x)
+#endif
+
+namespace
+boost
+    {
+#ifdef BOOST_NO_EXCEPTIONS
+    void throw_exception( std::exception const & e ); // user defined
+#else
+    template <class E>
+    void throw_exception( E const & e );
+#endif
+    }
+
+ + + + +
+
+
+ + diff --git a/doc/throw_exception.html b/doc/throw_exception.html index e75c902..895bb09 100644 --- a/doc/throw_exception.html +++ b/doc/throw_exception.html @@ -21,7 +21,7 @@

throw_exception

-

#include <boost/throw_exception.hpp>

+

#include <boost/throw_exception.hpp>

namespace
 boost
     {
@@ -44,7 +44,7 @@ boost
 

See Also:

BOOST_THROW_EXCEPTION
Boost Exception
-
boost/throw_exception.hpp
+
boost/throw_exception.hpp
Configuration Macros
enable_current_exception
Frequently Asked Questions
From ce5481b13121d66a67cd3a84787ce1a439450b83 Mon Sep 17 00:00:00 2001 From: Gennadiy Rozental Date: Sat, 6 Jun 2009 09:30:28 +0000 Subject: [PATCH 056/101] avoid C style casts [SVN r53666] --- include/boost/exception/exception.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index 6df93ac..fcd924e 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -303,7 +303,7 @@ boost struct enable_error_info_return_type { - typedef typename enable_error_info_helper::type type; + typedef typename enable_error_info_helper(0)))>::type type; }; } From d77aa6c801615e5e0f66ea3d90763d8081ace3b7 Mon Sep 17 00:00:00 2001 From: Gennadiy Rozental Date: Sat, 6 Jun 2009 09:39:27 +0000 Subject: [PATCH 057/101] avoid C style casts [SVN r53669] --- include/boost/exception/exception.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index fcd924e..9c3e0ac 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -303,7 +303,7 @@ boost struct enable_error_info_return_type { - typedef typename enable_error_info_helper(0)))>::type type; + typedef typename enable_error_info_helper(0)))>::type type; }; } From 19c5621747ac561ba01da810e12204c537fe61d0 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Fri, 3 Jul 2009 21:45:37 +0000 Subject: [PATCH 058/101] Added BOOST_ATTRIBUTE_NORETURN to suppress warnings in code calling BOOST_THROW_EXCEPTION. [SVN r54614] --- .../exception/detail/attribute_noreturn.hpp | 17 +++++++++++++++++ include/boost/throw_exception.hpp | 4 ++-- 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 include/boost/exception/detail/attribute_noreturn.hpp diff --git a/include/boost/exception/detail/attribute_noreturn.hpp b/include/boost/exception/detail/attribute_noreturn.hpp new file mode 100644 index 0000000..90a0306 --- /dev/null +++ b/include/boost/exception/detail/attribute_noreturn.hpp @@ -0,0 +1,17 @@ +//Copyright (c) 2009 Emil Dotchevski and Reverge Studios, Inc. + +//Distributed under the Boost Software License, Version 1.0. (See accompanying +//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef UUID_61531AB0680611DEADD5846855D89593 +#define UUID_61531AB0680611DEADD5846855D89593 + +#include + +#if defined(BOOST_MSVC) +#define BOOST_ATTRIBUTE_NORETURN __declspec(noreturn) +#else +#define BOOST_ATTRIBUTE_NORETURN +#endif + +#endif diff --git a/include/boost/throw_exception.hpp b/include/boost/throw_exception.hpp index da14339..2250bef 100644 --- a/include/boost/throw_exception.hpp +++ b/include/boost/throw_exception.hpp @@ -20,7 +20,7 @@ // http://www.boost.org/libs/utility/throw_exception.html // -#include +#include #include #include @@ -54,7 +54,7 @@ void throw_exception( std::exception const & e ); // user defined inline void throw_exception_assert_compatibility( std::exception const & ) { } -template inline void throw_exception( E const & e ) +template BOOST_ATTRIBUTE_NORETURN inline void throw_exception( E const & e ) { //All boost exceptions are required to derive std::exception, //to ensure compatibility with BOOST_NO_EXCEPTIONS. From 5ea7b4a6ba7974fee4afa4748460ac864f335524 Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Sun, 5 Jul 2009 09:25:58 +0000 Subject: [PATCH 059/101] Added support for GCC. [SVN r54668] --- include/boost/exception/detail/attribute_noreturn.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/boost/exception/detail/attribute_noreturn.hpp b/include/boost/exception/detail/attribute_noreturn.hpp index 90a0306..1cb0763 100644 --- a/include/boost/exception/detail/attribute_noreturn.hpp +++ b/include/boost/exception/detail/attribute_noreturn.hpp @@ -10,6 +10,8 @@ #if defined(BOOST_MSVC) #define BOOST_ATTRIBUTE_NORETURN __declspec(noreturn) +#elif defined(__GNUC__) +#define BOOST_ATTRIBUTE_NORETURN __attribute__((noreturn)) #else #define BOOST_ATTRIBUTE_NORETURN #endif From 01b514d8ae681b8098cba9013e74ec6617617536 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Sun, 5 Jul 2009 20:05:05 +0000 Subject: [PATCH 060/101] Please don't make unnecessary changes. [SVN r54681] --- include/boost/exception/exception.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index 9c3e0ac..6df93ac 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -303,7 +303,7 @@ boost struct enable_error_info_return_type { - typedef typename enable_error_info_helper(0)))>::type type; + typedef typename enable_error_info_helper::type type; }; } From 1e89a706fd72fe86e9b2b0468c3b87d83328a14d Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Fri, 10 Jul 2009 19:03:29 +0000 Subject: [PATCH 061/101] documentation update [SVN r54870] --- include/boost/exception/exception.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index 6df93ac..6233f19 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -80,13 +80,13 @@ boost template class error_info; - typedef error_info throw_function; - typedef error_info throw_file; - typedef error_info throw_line; + typedef error_info throw_function; + typedef error_info throw_file; + typedef error_info throw_line; template <> class - error_info + error_info { public: typedef char const * value_type; @@ -100,7 +100,7 @@ boost template <> class - error_info + error_info { public: typedef char const * value_type; @@ -114,7 +114,7 @@ boost template <> class - error_info + error_info { public: typedef int value_type; From 102fb300fe5cb115a0950e568e0b0e5607d32b2b Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Fri, 21 Aug 2009 22:28:44 +0000 Subject: [PATCH 062/101] mutable get_error_info support [SVN r55707] --- include/boost/exception/exception.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index 6233f19..f71f9f5 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -144,8 +144,8 @@ boost error_info_container { virtual char const * diagnostic_information() const = 0; - virtual shared_ptr get( type_info_ const & ) const = 0; - virtual void set( shared_ptr const &, type_info_ const & ) = 0; + virtual shared_ptr get( type_info_ const & ) const = 0; + virtual void set( shared_ptr const &, type_info_ const & ) = 0; virtual void add_ref() const = 0; virtual void release() const = 0; From 71eb9101a948c3d9888e8bb81496ae9cfba9a26c Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Sun, 27 Sep 2009 21:17:48 +0000 Subject: [PATCH 063/101] New function: diagnostic_information_what. [SVN r56448] --- include/boost/exception/exception.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index f71f9f5..e7faf59 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -143,7 +143,7 @@ boost struct error_info_container { - virtual char const * diagnostic_information() const = 0; + virtual char const * diagnostic_information( char const * ) const = 0; virtual shared_ptr get( type_info_ const & ) const = 0; virtual void set( shared_ptr const &, type_info_ const & ) = 0; virtual void add_ref() const = 0; @@ -169,7 +169,7 @@ boost template <> struct get_info; - char const * get_diagnostic_information( exception const & ); + char const * get_diagnostic_information( exception const &, char const * ); } class @@ -231,7 +231,7 @@ boost return x; } - friend char const * exception_detail::get_diagnostic_information( exception const & ); + friend char const * exception_detail::get_diagnostic_information( exception const &, char const * ); template friend E const & operator<<( E const &, error_info const & ); From 89064ecf51f5f38120b7d5e16f4c11ff8b075deb Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Thu, 22 Oct 2009 07:10:26 +0000 Subject: [PATCH 064/101] documentation update [SVN r57058] --- doc/BOOST_THROW_EXCEPTION.html | 8 +------- doc/boost_throw_exception_hpp.html | 9 +-------- doc/throw_exception.html | 12 +----------- 3 files changed, 3 insertions(+), 26 deletions(-) diff --git a/doc/BOOST_THROW_EXCEPTION.html b/doc/BOOST_THROW_EXCEPTION.html index 9647705..89395fb 100644 --- a/doc/BOOST_THROW_EXCEPTION.html +++ b/doc/BOOST_THROW_EXCEPTION.html @@ -35,18 +35,12 @@ #endif

This macro takes an exception object, records BOOST_CURRENT_FUNCTION, __FILE__ and __LINE__ in it, and forwards it to throw_exception. To recover this information at the catch site, use get_error_info; the information is also included in the message returned by diagnostic_information.

This macro takes an exception object, records BOOST_CURRENT_FUNCTION, __FILE__ and __LINE__ in it, and forwards it to throw_exception. To recover this information at the catch site, use get_error_info; the information is also included in the message returned by diagnostic_information.

+

This macro takes an exception object, records the current function name, __FILE__ and __LINE__ in it, and forwards it to throw_exception. To recover this information at the catch site, use get_error_info; the information is also included in the message returned by diagnostic_information.

diff --git a/doc/boost_throw_exception_hpp.html b/doc/boost_throw_exception_hpp.html index 735ac77..a99cd9b 100644 --- a/doc/boost_throw_exception_hpp.html +++ b/doc/boost_throw_exception_hpp.html @@ -27,7 +27,7 @@ #include <boost/current_function.hpp> #define BOOST_THROW_EXCEPTION(x)\ ::boost::throw_exception( ::boost::enable_error_info(x) <<\ - ::boost::throw_function(BOOST_CURRENT_FUNCTION) <<\ + ::boost::throw_function(BOOST_THROW_EXCEPTION_CURRENT_FUNCTION) <<\ ::boost::throw_file(__FILE__) <<\ ::boost::throw_line((int)__LINE__) ) #else diff --git a/doc/throw_exception.html b/doc/throw_exception.html index 4c24cda..eb03fdb 100644 --- a/doc/throw_exception.html +++ b/doc/throw_exception.html @@ -32,14 +32,17 @@ boost void throw_exception( E const & e ); #endif } -

Requirements:

-

E must derive publicly from std::exception.

-

Effects:

-
  • If BOOST_NO_EXCEPTIONS is not defined, boost::throw_exception(e) is equivalent to throw boost::enable_current_exception(boost::enable_error_info(e)), unless BOOST_EXCEPTION_DISABLE is defined, in which case boost::throw_exception(e) is equivalent to throw e;
  • +

Effects:

+
  • If BOOST_NO_EXCEPTIONS is not defined, boost::throw_exception(e) throws an exception of unspecified type that derives publicly from E and from boost::exception.
  • If BOOST_NO_EXCEPTIONS is defined, the function is left undefined, and the user is expected to supply an appropriate definition. Callers of throw_exception are allowed to assume that the function never returns; therefore, if the user-defined throw_exception returns, the behavior is undefined.
-

Note:

-

Under BOOST_NO_EXCEPTIONS, unless BOOST_EXCEPTION_DISABLE is also defined, users can examine the passed exception object using boost::get_error_info, or format an automatic diagnostic message using boost::diagnostic_information.

+

Requirements:

+

E must derive publicly from std::exception. E may or may not derive from boost::exception.

+

Notes:

+
  • The emitted exception can be intercepted as E &, std::exception &, or boost::exception &.
  • +
  • The emitted exception supports boost::exception_ptr.
  • +
  • If BOOST_EXCEPTION_DISABLE is defined and BOOST_NO_EXCEPTIONS is not defined, boost::throw_exception(e) equivalent to throw e.
  • +
diff --git a/include/boost/throw_exception.hpp b/include/boost/throw_exception.hpp index c1bff43..7b5d4ed 100644 --- a/include/boost/throw_exception.hpp +++ b/include/boost/throw_exception.hpp @@ -41,8 +41,11 @@ #if !defined( BOOST_EXCEPTION_DISABLE ) # include +#if !defined(BOOST_THROW_EXCEPTION_CURRENT_FUNCTION) # include -# define BOOST_THROW_EXCEPTION(x) ::boost::exception_detail::throw_exception_(x,BOOST_CURRENT_FUNCTION,__FILE__,__LINE__) +# define BOOST_THROW_EXCEPTION_CURRENT_FUNCTION BOOST_CURRENT_FUNCTION +#endif +# define BOOST_THROW_EXCEPTION(x) ::boost::exception_detail::throw_exception_(x,BOOST_THROW_EXCEPTION_CURRENT_FUNCTION,__FILE__,__LINE__) #else # define BOOST_THROW_EXCEPTION(x) ::boost::throw_exception(x) #endif From 9d1f5348501b1f27a7033fc7eba6e7abf07d4e59 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Tue, 10 Jul 2012 03:43:13 +0000 Subject: [PATCH 093/101] Ticket #7094, thanks 1czajnik [SVN r79398] --- include/boost/exception/exception.hpp | 2 +- include/boost/throw_exception.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index 42d2787..31d4317 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -5,7 +5,7 @@ #ifndef UUID_274DA366004E11DCB1DDFE2E56D89593 #define UUID_274DA366004E11DCB1DDFE2E56D89593 -#if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) #pragma GCC system_header #endif #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) diff --git a/include/boost/throw_exception.hpp b/include/boost/throw_exception.hpp index 7b5d4ed..200683e 100644 --- a/include/boost/throw_exception.hpp +++ b/include/boost/throw_exception.hpp @@ -1,6 +1,6 @@ #ifndef UUID_AA15E74A856F11E08B8D93F24824019B #define UUID_AA15E74A856F11E08B8D93F24824019B -#if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) #pragma GCC system_header #endif #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) From eca2c134790ac2f2e0813451871bf35308e928fd Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Sat, 31 Aug 2013 23:24:40 +0000 Subject: [PATCH 094/101] N3757 [SVN r85538] --- include/boost/exception/exception.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index 31d4317..d762cf8 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -207,6 +207,12 @@ boost class exception { + // + public: + template void set( typename Tag::type const & ); + template typename Tag::type const * get() const; + // + protected: exception(): From 24fd7039a146b9823890751b3b671d8909de199c Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 26 Sep 2013 13:02:51 +0000 Subject: [PATCH 095/101] Remove obsolete MSVC check from pragma guard git grep -h -B1 "^#\s*pragma once" | grep -v pragma | sort | uniq is now clean. [SVN r85952] --- include/boost/throw_exception.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/throw_exception.hpp b/include/boost/throw_exception.hpp index 200683e..5579a2d 100644 --- a/include/boost/throw_exception.hpp +++ b/include/boost/throw_exception.hpp @@ -9,7 +9,7 @@ // MS compatible compilers support #pragma once -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma once #endif From ec6bce5618096273ffcf1300f63cfcd570c616a7 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 30 Sep 2013 00:20:56 +0000 Subject: [PATCH 096/101] Exception: Remove obsolete MSVC version check. [SVN r86036] --- include/boost/throw_exception.hpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/include/boost/throw_exception.hpp b/include/boost/throw_exception.hpp index 5579a2d..d11e368 100644 --- a/include/boost/throw_exception.hpp +++ b/include/boost/throw_exception.hpp @@ -35,10 +35,6 @@ # define BOOST_EXCEPTION_DISABLE #endif -#if !defined( BOOST_EXCEPTION_DISABLE ) && defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, < 1310 ) -# define BOOST_EXCEPTION_DISABLE -#endif - #if !defined( BOOST_EXCEPTION_DISABLE ) # include #if !defined(BOOST_THROW_EXCEPTION_CURRENT_FUNCTION) From 949a2d948266bedfd5c347c718313658a1edf5e9 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 30 Sep 2013 16:01:02 +0000 Subject: [PATCH 097/101] Exception: Remove obsolete GCC version checks. [SVN r86074] --- include/boost/exception/exception.hpp | 2 +- include/boost/throw_exception.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index d762cf8..9f20a04 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -5,7 +5,7 @@ #ifndef UUID_274DA366004E11DCB1DDFE2E56D89593 #define UUID_274DA366004E11DCB1DDFE2E56D89593 -#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) #pragma GCC system_header #endif #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) diff --git a/include/boost/throw_exception.hpp b/include/boost/throw_exception.hpp index d11e368..d1c0515 100644 --- a/include/boost/throw_exception.hpp +++ b/include/boost/throw_exception.hpp @@ -1,6 +1,6 @@ #ifndef UUID_AA15E74A856F11E08B8D93F24824019B #define UUID_AA15E74A856F11E08B8D93F24824019B -#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) #pragma GCC system_header #endif #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) From 852a5a7dcdc4575918ba169f93aad96959ea2683 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 3 Jun 2014 01:52:12 +0300 Subject: [PATCH 098/101] Add test/Jamfile.v2. --- test/Jamfile.v2 | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 test/Jamfile.v2 diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 new file mode 100644 index 0000000..373d89c --- /dev/null +++ b/test/Jamfile.v2 @@ -0,0 +1,21 @@ +# Boost Exception Library test Jamfile +# +# Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc. +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +import testing ; + +project + : requirements + static + on + ; + +run 1-throw_exception_test.cpp ; +run 2-throw_exception_no_exceptions_test.cpp ; +run 3-throw_exception_no_integration_test.cpp ; +run 4-throw_exception_no_both_test.cpp ; + +compile-fail throw_exception_fail.cpp ; From 899c1d44df0540e73ec3fb7063376e406f05fb1c Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 3 Jun 2014 02:23:54 +0300 Subject: [PATCH 099/101] Revert "Exception: Remove obsolete GCC version checks." This reverts commit 949a2d948266bedfd5c347c718313658a1edf5e9. --- include/boost/exception/exception.hpp | 2 +- include/boost/throw_exception.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index 9f20a04..d762cf8 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -5,7 +5,7 @@ #ifndef UUID_274DA366004E11DCB1DDFE2E56D89593 #define UUID_274DA366004E11DCB1DDFE2E56D89593 -#if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) #pragma GCC system_header #endif #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) diff --git a/include/boost/throw_exception.hpp b/include/boost/throw_exception.hpp index d1c0515..d11e368 100644 --- a/include/boost/throw_exception.hpp +++ b/include/boost/throw_exception.hpp @@ -1,6 +1,6 @@ #ifndef UUID_AA15E74A856F11E08B8D93F24824019B #define UUID_AA15E74A856F11E08B8D93F24824019B -#if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) #pragma GCC system_header #endif #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) From cca5aa5395ee51cf405e5bb2108eb37e99af12df Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 3 Jun 2014 02:24:16 +0300 Subject: [PATCH 100/101] Revert "Exception: Remove obsolete MSVC version check." This reverts commit ec6bce5618096273ffcf1300f63cfcd570c616a7. --- include/boost/throw_exception.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/boost/throw_exception.hpp b/include/boost/throw_exception.hpp index d11e368..5579a2d 100644 --- a/include/boost/throw_exception.hpp +++ b/include/boost/throw_exception.hpp @@ -35,6 +35,10 @@ # define BOOST_EXCEPTION_DISABLE #endif +#if !defined( BOOST_EXCEPTION_DISABLE ) && defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, < 1310 ) +# define BOOST_EXCEPTION_DISABLE +#endif + #if !defined( BOOST_EXCEPTION_DISABLE ) # include #if !defined(BOOST_THROW_EXCEPTION_CURRENT_FUNCTION) From 513929ae73c0803fe5fe0007dae04a815cbb0baf Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 3 Jun 2014 02:25:09 +0300 Subject: [PATCH 101/101] Revert "Remove obsolete MSVC check from pragma guard" This reverts commit 24fd7039a146b9823890751b3b671d8909de199c. --- include/boost/throw_exception.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/throw_exception.hpp b/include/boost/throw_exception.hpp index 5579a2d..200683e 100644 --- a/include/boost/throw_exception.hpp +++ b/include/boost/throw_exception.hpp @@ -9,7 +9,7 @@ // MS compatible compilers support #pragma once -#if defined(_MSC_VER) +#if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif