diff --git a/example/cloning_1.cpp b/example/cloning_1.cpp index 5aa700a..a65ad5e 100644 --- a/example/cloning_1.cpp +++ b/example/cloning_1.cpp @@ -5,7 +5,6 @@ //This example shows how to enable cloning when throwing a boost::exception. -#include #include #include #include diff --git a/include/boost/exception/detail/counted_base.hpp b/include/boost/exception/detail/counted_base.hpp deleted file mode 100644 index d9f12d1..0000000 --- a/include/boost/exception/detail/counted_base.hpp +++ /dev/null @@ -1,45 +0,0 @@ -//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_DBA0D90C930911DCBA7B675A56D89593 -#define UUID_DBA0D90C930911DCBA7B675A56D89593 - -namespace -boost - { - 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() - { - } - }; - } - } - -#endif diff --git a/include/boost/exception/detail/refcount_ptr.hpp b/include/boost/exception/detail/refcount_ptr.hpp deleted file mode 100644 index 0c16292..0000000 --- a/include/boost/exception/detail/refcount_ptr.hpp +++ /dev/null @@ -1,79 +0,0 @@ -//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_490EADC876F011DDA2F00A4756D89593 -#define UUID_490EADC876F011DDA2F00A4756D89593 - -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_); - } - }; - } - } - -#endif diff --git a/include/boost/exception/enable_current_exception.hpp b/include/boost/exception/enable_current_exception.hpp deleted file mode 100644 index 5b277d3..0000000 --- a/include/boost/exception/enable_current_exception.hpp +++ /dev/null @@ -1,90 +0,0 @@ -//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_78CC85B2914F11DC8F47B48E55D89593 -#define UUID_78CC85B2914F11DC8F47B48E55D89593 - -#include - -namespace -boost - { - 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/exception/enable_error_info.hpp b/include/boost/exception/enable_error_info.hpp deleted file mode 100644 index 586a2d4..0000000 --- a/include/boost/exception/enable_error_info.hpp +++ /dev/null @@ -1,75 +0,0 @@ -//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_0C5D492E909711DCB658AD4556D89593 -#define UUID_0C5D492E909711DCB658AD4556D89593 - -#include - -namespace -boost - { - 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); - } - } - -#endif 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/exception_ptr.hpp b/include/boost/exception_ptr.hpp index 6462a80..1842fdb 100644 --- a/include/boost/exception_ptr.hpp +++ b/include/boost/exception_ptr.hpp @@ -6,7 +6,7 @@ #ifndef UUID_FA5836A2CADA11DC8CD47C8555D89593 #define UUID_FA5836A2CADA11DC8CD47C8555D89593 -#include +#include #include #include #include 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 diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index a3f1348..1d6ea16 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -37,8 +37,6 @@ compile-fail throw_exception_fail.cpp ; compile exception_ptr_hpp_test.cpp ; compile diagnostic_information_hpp_test.cpp ; -compile enable_current_exception_hpp_test.cpp ; -compile enable_error_info_hpp_test.cpp ; compile error_info_hpp_test.cpp ; compile exception_hpp_test.cpp ; compile get_error_info_hpp_test.cpp ; diff --git a/test/enable_current_exception_hpp_test.cpp b/test/enable_current_exception_hpp_test.cpp deleted file mode 100644 index 4745df5..0000000 --- a/test/enable_current_exception_hpp_test.cpp +++ /dev/null @@ -1,6 +0,0 @@ -//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 diff --git a/test/enable_error_info_hpp_test.cpp b/test/enable_error_info_hpp_test.cpp deleted file mode 100644 index 49badaf..0000000 --- a/test/enable_error_info_hpp_test.cpp +++ /dev/null @@ -1,6 +0,0 @@ -//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 diff --git a/test/helper1.cpp b/test/helper1.cpp index cfd734b..a839bff 100644 --- a/test/helper1.cpp +++ b/test/helper1.cpp @@ -3,7 +3,7 @@ //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 #include #include diff --git a/test/refcount_ptr_test.cpp b/test/refcount_ptr_test.cpp index 769e6a2..297450d 100644 --- a/test/refcount_ptr_test.cpp +++ b/test/refcount_ptr_test.cpp @@ -3,7 +3,7 @@ //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 #include struct