Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r60338 - in branches/release: boost boost/exception boost/exception/detail libs/exception/doc libs/exception/test
From: emil_at_[hidden]
Date: 2010-03-08 03:18:28


Author: emildotchevski
Date: 2010-03-08 03:18:25 EST (Mon, 08 Mar 2010)
New Revision: 60338
URL: http://svn.boost.org/trac/boost/changeset/60338

Log:
updating from trunk.
Added:
   branches/release/libs/exception/test/exception_ptr_test.cpp (contents, props changed)
Text files modified:
   branches/release/boost/exception/detail/error_info_impl.hpp | 6
   branches/release/boost/exception/detail/exception_ptr.hpp | 209 ++++++++++++++-------------------------
   branches/release/boost/exception/detail/is_output_streamable.hpp | 17 ++
   branches/release/boost/exception/detail/type_info.hpp | 14 +
   branches/release/boost/exception/diagnostic_information.hpp | 8
   branches/release/boost/exception/errinfo_nested_exception.hpp | 4
   branches/release/boost/exception/exception.hpp | 98 ++++++++++--------
   branches/release/boost/exception/info.hpp | 48 +++++++-
   branches/release/boost/throw_exception.hpp | 24 +++
   branches/release/libs/exception/doc/copy_exception.html | 2
   branches/release/libs/exception/doc/current_exception.html | 3
   branches/release/libs/exception/doc/exception_ptr.html | 9
   branches/release/libs/exception/doc/rethrow_exception.html | 2
   branches/release/libs/exception/test/Jamfile.v2 | 3
   branches/release/libs/exception/test/copy_exception_test.cpp | 100 +++++++++++++++++-
   branches/release/libs/exception/test/errinfos_test.cpp | 2
   branches/release/libs/exception/test/error_info_test.cpp | 19 +++
   branches/release/libs/exception/test/is_output_streamable_test.cpp | 18 ++
   18 files changed, 359 insertions(+), 227 deletions(-)

Modified: branches/release/boost/exception/detail/error_info_impl.hpp
==============================================================================
--- branches/release/boost/exception/detail/error_info_impl.hpp (original)
+++ branches/release/boost/exception/detail/error_info_impl.hpp 2010-03-08 03:18:25 EST (Mon, 08 Mar 2010)
@@ -1,4 +1,4 @@
-//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
+//Copyright (c) 2006-2010 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)
@@ -25,7 +25,7 @@
             {
             public:
 
- virtual char const * tag_typeid_name() const = 0;
+ virtual std::string tag_typeid_name() const = 0;
             virtual std::string value_as_string() const = 0;
 
             protected:
@@ -62,7 +62,7 @@
 
         private:
 
- char const * tag_typeid_name() const;
+ std::string tag_typeid_name() const;
         std::string value_as_string() const;
 
         value_type value_;

Modified: branches/release/boost/exception/detail/exception_ptr.hpp
==============================================================================
--- branches/release/boost/exception/detail/exception_ptr.hpp (original)
+++ branches/release/boost/exception/detail/exception_ptr.hpp 2010-03-08 03:18:25 EST (Mon, 08 Mar 2010)
@@ -28,6 +28,26 @@
 namespace
 boost
     {
+ typedef shared_ptr<exception_detail::clone_base const> exception_ptr;
+
+ exception_ptr current_exception();
+
+ template <class T>
+ inline
+ exception_ptr
+ copy_exception( T const & e )
+ {
+ try
+ {
+ throw enable_current_exception(e);
+ }
+ catch(
+ ... )
+ {
+ return current_exception();
+ }
+ }
+
 #ifndef BOOST_NO_RTTI
     typedef error_info<struct tag_original_exception_type,std::type_info const *> original_exception_type;
 
@@ -39,91 +59,45 @@
         }
 #endif
 
- class exception_ptr;
- exception_ptr current_exception();
- void rethrow_exception( exception_ptr const & );
-
- class
- exception_ptr
+ namespace
+ exception_detail
         {
- typedef bool exception_ptr::*unspecified_bool_type;
- friend exception_ptr current_exception();
- friend void rethrow_exception( exception_ptr const & );
-
- shared_ptr<exception_detail::clone_base const> c_;
- bool bad_alloc_;
-
         struct
- bad_alloc_tag
- {
- };
-
- explicit
- exception_ptr( bad_alloc_tag ):
- bad_alloc_(true)
- {
- }
-
- explicit
- exception_ptr( shared_ptr<exception_detail::clone_base const> const & c ):
- c_(c),
- bad_alloc_(false)
- {
- BOOST_ASSERT(c);
- }
-
- void
- rethrow() const
- {
- BOOST_ASSERT(*this);
- if( bad_alloc_ )
- throw enable_current_exception(std::bad_alloc());
- else
- c_->rethrow();
- }
-
- bool
- empty() const
- {
- return !bad_alloc_ && !c_;
- }
-
- public:
-
- exception_ptr():
- bad_alloc_(false)
- {
- }
-
- ~exception_ptr() throw()
- {
- }
+ bad_alloc_:
+ boost::exception,
+ std::bad_alloc
+ {
+ };
 
- operator unspecified_bool_type() const
+ template <int Dummy>
+ exception_ptr
+ get_bad_alloc()
             {
- return empty() ? 0 : &exception_ptr::bad_alloc_;
+ static exception_ptr e = boost::copy_exception(
+ bad_alloc_() <<
+ throw_function("boost::current_exception()") <<
+ throw_file(__FILE__) <<
+ throw_line(__LINE__) );
+ return e;
             }
 
- friend
- bool
- operator==( exception_ptr const & a, exception_ptr const & b )
+ template <int Dummy>
+ struct
+ exception_ptr_bad_alloc
             {
- return a.c_==b.c_ && a.bad_alloc_==b.bad_alloc_;
- }
+ static exception_ptr const e;
+ };
 
- friend
- bool
- operator!=( exception_ptr const & a, exception_ptr const & b )
- {
- return !(a==b);
- }
- };
+ template <int Dummy>
+ exception_ptr const
+ exception_ptr_bad_alloc<Dummy>::
+ e = get_bad_alloc<Dummy>();
+ }
 
     class
     unknown_exception:
- public exception,
- public std::exception,
- public exception_detail::clone_base
+ public boost::exception,
+ public std::exception
         {
         public:
 
@@ -150,18 +124,6 @@
 
         private:
 
- exception_detail::clone_base const *
- clone() const
- {
- return new unknown_exception(*this);
- }
-
- void
- rethrow() const
- {
- throw*this;
- }
-
         template <class E>
         void
         add_original_type( E const & e )
@@ -179,8 +141,7 @@
         class
         current_exception_std_exception_wrapper:
             public T,
- public boost::exception,
- public clone_base
+ public boost::exception
             {
             public:
 
@@ -204,18 +165,6 @@
 
             private:
 
- clone_base const *
- clone() const
- {
- return new current_exception_std_exception_wrapper(*this);
- }
-
- void
- rethrow() const
- {
- throw *this;
- }
-
             template <class E>
             void
             add_original_type( E const & e )
@@ -228,7 +177,7 @@
 
 #ifdef BOOST_NO_RTTI
         template <class T>
- exception const *
+ boost::exception const *
         get_boost_exception( T const * )
             {
             try
@@ -236,7 +185,7 @@
                 throw;
                 }
             catch(
- exception & x )
+ boost::exception & x )
                 {
                 return &x;
                 }
@@ -247,50 +196,50 @@
             }
 #else
         template <class T>
- exception const *
+ boost::exception const *
         get_boost_exception( T const * x )
             {
- return dynamic_cast<exception const *>(x);
+ return dynamic_cast<boost::exception const *>(x);
             }
 #endif
 
         template <class T>
         inline
- shared_ptr<clone_base const>
+ exception_ptr
         current_exception_std_exception( T const & e1 )
             {
             if( boost::exception const * e2 = get_boost_exception(&e1) )
- return shared_ptr<current_exception_std_exception_wrapper<T> const>(new current_exception_std_exception_wrapper<T>(e1,*e2));
+ return boost::copy_exception(current_exception_std_exception_wrapper<T>(e1,*e2));
             else
- return shared_ptr<current_exception_std_exception_wrapper<T> const>(new current_exception_std_exception_wrapper<T>(e1));
+ return boost::copy_exception(current_exception_std_exception_wrapper<T>(e1));
             }
 
         inline
- shared_ptr<clone_base const>
+ exception_ptr
         current_exception_unknown_exception()
             {
- return shared_ptr<unknown_exception const>(new unknown_exception());
+ return boost::copy_exception(unknown_exception());
             }
 
         inline
- shared_ptr<clone_base const>
+ exception_ptr
         current_exception_unknown_boost_exception( boost::exception const & e )
             {
- return shared_ptr<unknown_exception const>(new unknown_exception(e));
+ return boost::copy_exception(unknown_exception(e));
             }
 
         inline
- shared_ptr<clone_base const>
+ exception_ptr
         current_exception_unknown_std_exception( std::exception const & e )
             {
             if( boost::exception const * be = get_boost_exception(&e) )
                 return current_exception_unknown_boost_exception(*be);
             else
- return shared_ptr<unknown_exception const>(new unknown_exception(e));
+ return boost::copy_exception(unknown_exception(e));
             }
 
         inline
- shared_ptr<clone_base const>
+ exception_ptr
         current_exception_impl()
             {
             try
@@ -300,7 +249,7 @@
             catch(
             exception_detail::clone_base & e )
                 {
- return shared_ptr<exception_detail::clone_base const>(e.clone());
+ return exception_ptr(e.clone());
                 }
             catch(
             std::domain_error & e )
@@ -396,24 +345,28 @@
     exception_ptr
     current_exception()
         {
+ exception_ptr ret;
+ BOOST_ASSERT(!ret);
         try
             {
- return exception_ptr(exception_detail::current_exception_impl());
+ ret=exception_detail::current_exception_impl();
             }
         catch(
         std::bad_alloc & )
             {
+ ret=exception_detail::exception_ptr_bad_alloc<42>::e;
             }
         catch(
         ... )
             {
             try
                 {
- return exception_ptr(exception_detail::current_exception_std_exception(std::bad_exception()));
+ ret=exception_detail::current_exception_std_exception(std::bad_exception());
                 }
             catch(
             std::bad_alloc & )
                 {
+ ret=exception_detail::exception_ptr_bad_alloc<42>::e;
                 }
             catch(
             ... )
@@ -421,30 +374,16 @@
                 BOOST_ASSERT(0);
                 }
             }
- return exception_ptr(exception_ptr::bad_alloc_tag());
- }
-
- template <class T>
- inline
- exception_ptr
- copy_exception( T const & e )
- {
- try
- {
- throw enable_current_exception(e);
- }
- catch(
- ... )
- {
- return current_exception();
- }
+ BOOST_ASSERT(ret);
+ return ret;
         }
 
     inline
     void
     rethrow_exception( exception_ptr const & p )
         {
- p.rethrow();
+ BOOST_ASSERT(p);
+ p->rethrow();
         }
 
     inline

Modified: branches/release/boost/exception/detail/is_output_streamable.hpp
==============================================================================
--- branches/release/boost/exception/detail/is_output_streamable.hpp (original)
+++ branches/release/boost/exception/detail/is_output_streamable.hpp 2010-03-08 03:18:25 EST (Mon, 08 Mar 2010)
@@ -20,8 +20,21 @@
     namespace
     to_string_detail
         {
- template <class T,class CharT,class Traits>
- char operator<<( std::basic_ostream<CharT,Traits> &, T const & );
+ struct
+ partial_ordering_helper1
+ {
+ template <class CharT,class Traits>
+ partial_ordering_helper1( std::basic_ostream<CharT,Traits> & );
+ };
+
+ struct
+ partial_ordering_helper2
+ {
+ template <class T>
+ partial_ordering_helper2( T const & );
+ };
+
+ char operator<<( partial_ordering_helper1, partial_ordering_helper2 );
 
         template <class T,class CharT,class Traits>
         struct

Modified: branches/release/boost/exception/detail/type_info.hpp
==============================================================================
--- branches/release/boost/exception/detail/type_info.hpp (original)
+++ branches/release/boost/exception/detail/type_info.hpp 2010-03-08 03:18:25 EST (Mon, 08 Mar 2010)
@@ -1,4 +1,4 @@
-//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
+//Copyright (c) 2006-2010 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)
@@ -15,31 +15,35 @@
 #include <boost/detail/sp_typeinfo.hpp>
 #include <boost/current_function.hpp>
 #include <boost/config.hpp>
+#ifndef BOOST_NO_TYPEID
+#include <boost/units/detail/utility.hpp>
+#endif
+#include <string>
 
 namespace
 boost
     {
     template <class T>
     inline
- char const *
+ std::string
     tag_type_name()
         {
 #ifdef BOOST_NO_TYPEID
         return BOOST_CURRENT_FUNCTION;
 #else
- return typeid(T*).name();
+ return units::detail::demangle(typeid(T*).name());
 #endif
         }
 
     template <class T>
     inline
- char const *
+ std::string
     type_name()
         {
 #ifdef BOOST_NO_TYPEID
         return BOOST_CURRENT_FUNCTION;
 #else
- return typeid(T).name();
+ return units::detail::demangle(typeid(T).name());
 #endif
         }
 

Modified: branches/release/boost/exception/diagnostic_information.hpp
==============================================================================
--- branches/release/boost/exception/diagnostic_information.hpp (original)
+++ branches/release/boost/exception/diagnostic_information.hpp 2010-03-08 03:18:25 EST (Mon, 08 Mar 2010)
@@ -1,4 +1,4 @@
-//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
+//Copyright (c) 2006-2010 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)
@@ -15,7 +15,9 @@
 #include <boost/config.hpp>
 #include <boost/exception/get_error_info.hpp>
 #include <boost/utility/enable_if.hpp>
-#include <boost/config.hpp>
+#ifndef BOOST_NO_RTTI
+#include <boost/units/detail/utility.hpp>
+#endif
 #include <exception>
 #include <sstream>
 #include <string>
@@ -135,7 +137,7 @@
                 }
 #ifndef BOOST_NO_RTTI
             tmp << std::string("Dynamic exception type: ") <<
- (be?BOOST_EXCEPTION_DYNAMIC_TYPEID(*be):BOOST_EXCEPTION_DYNAMIC_TYPEID(*se)).type_.name() << '\n';
+ units::detail::demangle((be?BOOST_EXCEPTION_DYNAMIC_TYPEID(*be):BOOST_EXCEPTION_DYNAMIC_TYPEID(*se)).type_.name()) << '\n';
 #endif
             if( with_what && se )
                 tmp << "std::exception::what: " << wh << '\n';

Modified: branches/release/boost/exception/errinfo_nested_exception.hpp
==============================================================================
--- branches/release/boost/exception/errinfo_nested_exception.hpp (original)
+++ branches/release/boost/exception/errinfo_nested_exception.hpp 2010-03-08 03:18:25 EST (Mon, 08 Mar 2010)
@@ -9,8 +9,10 @@
 namespace
 boost
     {
+ namespace exception_detail { class clone_base; };
     template <class Tag,class T> class error_info;
- class exception_ptr;
+ template <class T> class shared_ptr;
+ typedef shared_ptr<exception_detail::clone_base const> exception_ptr;
     typedef error_info<struct errinfo_nested_exception_,exception_ptr> errinfo_nested_exception;
     }
 

Modified: branches/release/boost/exception/exception.hpp
==============================================================================
--- branches/release/boost/exception/exception.hpp (original)
+++ branches/release/boost/exception/exception.hpp 2010-03-08 03:18:25 EST (Mon, 08 Mar 2010)
@@ -132,18 +132,6 @@
             }
         };
 
- template <class E,class Tag,class T>
- E const & operator<<( E const &, error_info<Tag,T> const & );
-
- template <class E>
- E const & operator<<( E const &, throw_function const & );
-
- template <class E>
- E const & operator<<( E const &, throw_file const & );
-
- template <class E>
- E const & operator<<( E const &, throw_line const & );
-
     class exception;
 
     template <class>
@@ -163,6 +151,7 @@
             virtual void set( shared_ptr<error_info_base> const &, type_info_ const & ) = 0;
             virtual void add_ref() const = 0;
             virtual void release() const = 0;
+ virtual refcount_ptr<exception_detail::error_info_container> clone() const = 0;
 
             protected:
 
@@ -184,6 +173,20 @@
         struct get_info<throw_line>;
 
         char const * get_diagnostic_information( exception const &, char const * );
+
+ void copy_boost_exception( exception *, exception const * );
+
+ template <class E,class Tag,class T>
+ E const & set_info( E const &, error_info<Tag,T> const & );
+
+ template <class E>
+ E const & set_info( E const &, throw_function const & );
+
+ template <class E>
+ E const & set_info( E const &, throw_file const & );
+
+ template <class E>
+ E const & set_info( E const &, throw_line const & );
         }
 
     class
@@ -216,30 +219,31 @@
 #endif
             ;
 
-#if defined(__MWERKS__) && __MWERKS__<=0x3207
+#if (defined(__MWERKS__) && __MWERKS__<=0x3207) || (defined(_MSC_VER) && _MSC_VER<=1310)
         public:
 #else
         private:
 
         template <class E>
- friend E const & operator<<( E const &, throw_function const & );
+ friend E const & exception_detail::set_info( E const &, throw_function const & );
 
         template <class E>
- friend E const & operator<<( E const &, throw_file const & );
+ friend E const & exception_detail::set_info( E const &, throw_file const & );
 
         template <class E>
- friend E const & operator<<( E const &, throw_line const & );
-
- friend char const * exception_detail::get_diagnostic_information( exception const &, char const * );
+ friend E const & exception_detail::set_info( E const &, throw_line const & );
 
         template <class E,class Tag,class T>
- friend E const & operator<<( E const &, error_info<Tag,T> const & );
+ friend E const & exception_detail::set_info( E const &, error_info<Tag,T> const & );
+
+ friend char const * exception_detail::get_diagnostic_information( exception const &, char const * );
 
         template <class>
         friend struct exception_detail::get_info;
         friend struct exception_detail::get_info<throw_function>;
         friend struct exception_detail::get_info<throw_file>;
         friend struct exception_detail::get_info<throw_line>;
+ friend void exception_detail::copy_boost_exception( exception *, exception const * );
 #endif
         mutable exception_detail::refcount_ptr<exception_detail::error_info_container> data_;
         mutable char const * throw_function_;
@@ -253,28 +257,32 @@
         {
         }
 
- template <class E>
- E const &
- operator<<( E const & x, throw_function const & y )
+ namespace
+ exception_detail
         {
- x.throw_function_=y.v_;
- return x;
- }
+ template <class E>
+ E const &
+ set_info( E const & x, throw_function const & y )
+ {
+ x.throw_function_=y.v_;
+ return x;
+ }
 
- template <class E>
- E const &
- operator<<( E const & x, throw_file const & y )
- {
- x.throw_file_=y.v_;
- return x;
- }
+ template <class E>
+ E const &
+ set_info( E const & x, throw_file const & y )
+ {
+ x.throw_file_=y.v_;
+ return x;
+ }
 
- template <class E>
- E const &
- operator<<( E const & x, throw_line const & y )
- {
- x.throw_line_=y.v_;
- return x;
+ template <class E>
+ E const &
+ set_info( E const & x, throw_line const & y )
+ {
+ x.throw_line_=y.v_;
+ return x;
+ }
         }
 
     ////////////////////////////////////////////////////////////////////////
@@ -300,10 +308,10 @@
             };
 
         struct large_size { char c[256]; };
- large_size dispatch( exception * );
+ large_size dispatch_boost_exception( exception const * );
 
         struct small_size { };
- small_size dispatch( void * );
+ small_size dispatch_boost_exception( void const * );
 
         template <class,int>
         struct enable_error_info_helper;
@@ -326,7 +334,7 @@
         struct
         enable_error_info_return_type
             {
- typedef typename enable_error_info_helper<T,sizeof(exception_detail::dispatch((T*)0))>::type type;
+ typedef typename enable_error_info_helper<T,sizeof(exception_detail::dispatch_boost_exception((T*)0))>::type type;
             };
         }
 
@@ -363,7 +371,13 @@
         void
         copy_boost_exception( exception * a, exception const * b )
             {
- *a = *b;
+ refcount_ptr<error_info_container> data;
+ if( error_info_container * d=b->data_.get() )
+ data = d->clone();
+ a->throw_file_ = b->throw_file_;
+ a->throw_line_ = b->throw_line_;
+ a->throw_function_ = b->throw_function_;
+ a->data_ = data;
             }
 
         inline

Modified: branches/release/boost/exception/info.hpp
==============================================================================
--- branches/release/boost/exception/info.hpp (original)
+++ branches/release/boost/exception/info.hpp 2010-03-08 03:18:25 EST (Mon, 08 Mar 2010)
@@ -1,4 +1,4 @@
-//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
+//Copyright (c) 2006-2010 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)
@@ -47,7 +47,7 @@
 
     template <class Tag,class T>
     inline
- char const *
+ std::string
     error_info<Tag,T>::
     tag_typeid_name() const
         {
@@ -131,6 +131,9 @@
             mutable std::string diagnostic_info_str_;
             mutable int count_;
 
+ error_info_container_impl( error_info_container_impl const & );
+ error_info_container_impl & operator=( error_info_container const & );
+
             void
             add_ref() const
                 {
@@ -143,21 +146,46 @@
                 if( !--count_ )
                     delete this;
                 }
+
+ refcount_ptr<error_info_container>
+ clone() const
+ {
+ refcount_ptr<error_info_container> p;
+ error_info_container_impl * c=new error_info_container_impl;
+ p.adopt(c);
+ c->info_ = info_;
+ return p;
+ }
+ };
+
+ template <class E,class Tag,class T>
+ inline
+ E const &
+ set_info( E const & x, error_info<Tag,T> const & v )
+ {
+ typedef error_info<Tag,T> error_info_tag_t;
+ shared_ptr<error_info_tag_t> p( new error_info_tag_t(v) );
+ exception_detail::error_info_container * c=x.data_.get();
+ if( !c )
+ x.data_.adopt(c=new exception_detail::error_info_container_impl);
+ c->set(p,BOOST_EXCEPTION_STATIC_TYPEID(error_info_tag_t));
+ return x;
+ }
+
+ template <class T>
+ struct
+ derives_boost_exception
+ {
+ enum e { value = (sizeof(dispatch_boost_exception((T*)0))==sizeof(large_size)) };
             };
         }
 
     template <class E,class Tag,class T>
     inline
- E const &
+ typename enable_if<exception_detail::derives_boost_exception<E>,E const &>::type
     operator<<( E const & x, error_info<Tag,T> const & v )
         {
- typedef error_info<Tag,T> error_info_tag_t;
- shared_ptr<error_info_tag_t> p( new error_info_tag_t(v) );
- exception_detail::error_info_container * c=x.data_.get();
- if( !c )
- x.data_.adopt(c=new exception_detail::error_info_container_impl);
- c->set(p,BOOST_EXCEPTION_STATIC_TYPEID(error_info_tag_t));
- return x;
+ return exception_detail::set_info(x,v);
         }
     }
 

Modified: branches/release/boost/throw_exception.hpp
==============================================================================
--- branches/release/boost/throw_exception.hpp (original)
+++ branches/release/boost/throw_exception.hpp 2010-03-08 03:18:25 EST (Mon, 08 Mar 2010)
@@ -36,16 +36,32 @@
 #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(__LINE__))
+# define BOOST_THROW_EXCEPTION(x) ::boost::exception_detail::throw_exception_(x,BOOST_CURRENT_FUNCTION,__FILE__,__LINE__)
 #else
 # define BOOST_THROW_EXCEPTION(x) ::boost::throw_exception(x)
 #endif
 
 namespace boost
 {
+#if !defined( BOOST_EXCEPTION_DISABLE )
+ namespace
+ exception_detail
+ {
+ template <class E>
+ void
+ throw_exception_( E const & x, char const * current_function, char const * file, int line )
+ {
+ throw_exception(
+ set_info(
+ set_info(
+ set_info(
+ enable_error_info(x),
+ throw_function(current_function)),
+ throw_file(file)),
+ throw_line(line)));
+ }
+ }
+#endif
 
 #ifdef BOOST_NO_EXCEPTIONS
 

Modified: branches/release/libs/exception/doc/copy_exception.html
==============================================================================
--- branches/release/libs/exception/doc/copy_exception.html (original)
+++ branches/release/libs/exception/doc/copy_exception.html 2010-03-08 03:18:25 EST (Mon, 08 Mar 2010)
@@ -39,7 +39,7 @@
     return <span class="RenoLink">current_exception</span>();
     }</pre>
 </div><div class="RenoAutoDIV"><div class="RenoHR"><hr/></div>
-See also: <span class="RenoPageList">Boost Exception&nbsp;| boost/exception_ptr.hpp</span>
+See also: <span class="RenoPageList">Boost Exception&nbsp;| boost/exception_ptr.hpp&nbsp;| current_exception</span>
 </div>
 <!-- Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc. -->
 <!-- Distributed under the Boost Software License, Version 1.0. (See accompanying -->

Modified: branches/release/libs/exception/doc/current_exception.html
==============================================================================
--- branches/release/libs/exception/doc/current_exception.html (original)
+++ branches/release/libs/exception/doc/current_exception.html 2010-03-08 03:18:25 EST (Mon, 08 Mar 2010)
@@ -29,6 +29,7 @@
     }</pre>
 </div><h4>Requirements:</h4>
 <p>The <span class="RenoLink">current_exception</span> function must not be called outside of a catch block.</p>
+<p>In addition, to safely copy an exception from one thread to another, if the exception object is copied by <span class="RenoLink">current_exception</span> or <span class="RenoLink">copy_exception</span>, the two copies must not have shared state. Exceptions that have value-type semantics (as well as the boost::<span class="RenoLink">exception</span> type itself) satisfy this requirement.</p>
 <h4>Returns:</h4>
 <div><ul><li> An <span class="RenoLink">exception_ptr</span> that refers to the currently handled exception or a copy of the currently handled exception.</li>
 <li> If the function needs to allocate memory and the attempt fails, it returns an <span class="RenoLink">exception_ptr</span> that refers to an instance of std::bad_alloc.</li>
@@ -43,7 +44,7 @@
 </li>
 </ul></div>
 </div><div class="RenoAutoDIV"><div class="RenoHR"><hr/></div>
-See also: <span class="RenoPageList">Boost Exception&nbsp;| boost/exception_ptr.hpp&nbsp;| copy_exception&nbsp;| enable_current_exception&nbsp;| exception_ptr&nbsp;| Frequently Asked Questions&nbsp;| original_exception_type&nbsp;| unknown_exception</span>
+See also: <span class="RenoPageList">Boost Exception&nbsp;| boost/exception_ptr.hpp&nbsp;| copy_exception&nbsp;| enable_current_exception&nbsp;| Frequently Asked Questions&nbsp;| original_exception_type&nbsp;| unknown_exception</span>
 </div>
 <!-- Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc. -->
 <!-- Distributed under the Boost Software License, Version 1.0. (See accompanying -->

Modified: branches/release/libs/exception/doc/exception_ptr.html
==============================================================================
--- branches/release/libs/exception/doc/exception_ptr.html (original)
+++ branches/release/libs/exception/doc/exception_ptr.html 2010-03-08 03:18:25 EST (Mon, 08 Mar 2010)
@@ -31,11 +31,12 @@
 <p>The referenced object remains valid at least as long as there is an <span class="RenoLink">exception_ptr</span> object that refers to it.</p>
 <p>Two instances of <span class="RenoLink">exception_ptr</span> are equivalent and compare equal if and only if they refer to the same exception.</p>
 <p>The default constructor of <span class="RenoLink">exception_ptr</span> produces the null value of the type. The null value is equivalent only to itself.</p>
-<h4>Thread safety</h4>
-<div><ul><li> It is legal for multiple threads to hold <span class="RenoLink">exception_ptr</span> references to the same exception object.</li>
-<li> It is illegal for multiple threads to modify the same <span class="RenoLink">exception_ptr</span> object concurrently.</li>
-<li> While calling <span class="RenoLink">current_exception</span> makes a copy of the current exception object, it is still possible for the two copies to share internal state. Therefore, in general it is not safe to call <span class="RenoLink">rethrow_exception</span> concurrently to throw the same exception object into multiple threads.</li>
+<h4>Thread safety:</h4>
+<p>The <span class="RenoLink">exception_ptr</span> type is "as thread-safe as built-in types":</p>
+<div><ul><li> An <span class="RenoLink">exception_ptr</span> instance can be "read" simultaneously by multiple threads</li>
+<li> Different <span class="RenoLink">exception_ptr</span> instances can be "written to" simultaneously by multiple threads, even when these instances refer to the same exception object</li>
 </ul></div>
+<p>All other simultaneous accesses result in undefined behavior.</p>
 <h4>Nesting of exceptions:</h4>
 <p>An <span class="RenoLink">exception_ptr</span> can be added as <span class="RenoLink">error_info</span> to any boost::<span class="RenoLink">exception</span>. This is a convenient way to nest exceptions. There is no limit on the depth of the nesting, however cyclic references result in undefined behavior.</p>
 </div><div class="RenoAutoDIV"><div class="RenoHR"><hr/></div>

Modified: branches/release/libs/exception/doc/rethrow_exception.html
==============================================================================
--- branches/release/libs/exception/doc/rethrow_exception.html (original)
+++ branches/release/libs/exception/doc/rethrow_exception.html 2010-03-08 03:18:25 EST (Mon, 08 Mar 2010)
@@ -32,7 +32,7 @@
 <h4>Throws:</h4>
 <p>The exception to which ep refers.</p>
 </div><div class="RenoAutoDIV"><div class="RenoHR"><hr/></div>
-See also: <span class="RenoPageList">Boost Exception&nbsp;| boost/exception_ptr.hpp&nbsp;| diagnostic_information&nbsp;| exception_ptr</span>
+See also: <span class="RenoPageList">Boost Exception&nbsp;| boost/exception_ptr.hpp&nbsp;| diagnostic_information</span>
 </div>
 <!-- Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc. -->
 <!-- Distributed under the Boost Software License, Version 1.0. (See accompanying -->

Modified: branches/release/libs/exception/test/Jamfile.v2
==============================================================================
--- branches/release/libs/exception/test/Jamfile.v2 (original)
+++ branches/release/libs/exception/test/Jamfile.v2 2010-03-08 03:18:25 EST (Mon, 08 Mar 2010)
@@ -24,7 +24,7 @@
 run 3-throw_exception_no_integration_test.cpp ;
 run 4-throw_exception_no_both_test.cpp ;
 run cloning_test.cpp ;
-run copy_exception_test.cpp ;
+run copy_exception_test.cpp /boost//thread : : : <threading>multi ;
 run unknown_exception_test.cpp ;
 run exception_test.cpp ;
 run enable_error_info_test.cpp helper1.cpp ;
@@ -36,6 +36,7 @@
 run current_exception_cast_test.cpp ;
 run no_exceptions_test.cpp : : : <exception-handling>off ;
 run errinfos_test.cpp ;
+run exception_ptr_test.cpp /boost//thread : : : <threading>multi ;
 compile-fail exception_fail.cpp ;
 compile-fail throw_exception_fail.cpp ;
 compile-fail error_info_const_fail.cpp ;

Modified: branches/release/libs/exception/test/copy_exception_test.cpp
==============================================================================
--- branches/release/libs/exception/test/copy_exception_test.cpp (original)
+++ branches/release/libs/exception/test/copy_exception_test.cpp 2010-03-08 03:18:25 EST (Mon, 08 Mar 2010)
@@ -4,25 +4,106 @@
 //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 
 #include <boost/exception_ptr.hpp>
+#include <boost/exception/get_error_info.hpp>
+#include <boost/thread.hpp>
 #include <boost/detail/lightweight_test.hpp>
 
+typedef boost::error_info<struct tag_answer,int> answer;
+
 struct
-test_exception:
- std::exception
+err:
+ virtual boost::exception,
+ virtual std::exception
     {
     };
 
-int
-main()
+class
+future
+ {
+ public:
+
+ future ():
+ ready_ (false)
+ {
+ }
+
+ void
+ set_exception( boost::exception_ptr const & e )
+ {
+ boost::unique_lock<boost::mutex> lck (mux_);
+ exc_ = e;
+ ready_ = true;
+ cond_.notify_all();
+ }
+
+ void
+ get_exception() const
+ {
+ boost::unique_lock<boost::mutex> lck (mux_);
+ while (! ready_)
+ cond_.wait (lck);
+ rethrow_exception (exc_);
+ }
+
+ private:
+
+ bool ready_;
+ boost::exception_ptr exc_;
+ mutable boost::mutex mux_;
+ mutable boost::condition_variable cond_;
+ };
+
+void
+producer( future & f )
+ {
+ f.set_exception (boost::copy_exception (err () << answer(42)));
+ }
+
+void
+consumer()
     {
- boost::exception_ptr p = boost::copy_exception(test_exception());
+ future f;
+ boost::thread thr (boost::bind (&producer, boost::ref (f)));
+ try
+ {
+ f.get_exception ();
+ }
+ catch(
+ err & e )
+ {
+ int const * ans=boost::get_error_info<answer>(e);
+ BOOST_TEST(ans && *ans==42);
+ }
+ thr.join();
+ }
+
+void
+consume()
+ {
+ for( int i=0; i!=100; ++i )
+ consumer();
+ }
+
+void
+thread_test()
+ {
+ boost::thread_group grp;
+ for( int i=0; i!=50; ++i )
+ grp.create_thread(&consume);
+ grp.join_all ();
+ }
+
+void
+simple_test()
+ {
+ boost::exception_ptr p = boost::copy_exception(err());
     try
         {
         rethrow_exception(p);
         BOOST_TEST(false);
         }
     catch(
- test_exception & )
+ err & )
         {
         }
     catch(
@@ -30,5 +111,12 @@
         {
         BOOST_TEST(false);
         }
+ }
+
+int
+main()
+ {
+ simple_test();
+ thread_test();
     return boost::report_errors();
     }

Modified: branches/release/libs/exception/test/errinfos_test.cpp
==============================================================================
--- branches/release/libs/exception/test/errinfos_test.cpp (original)
+++ branches/release/libs/exception/test/errinfos_test.cpp 2010-03-08 03:18:25 EST (Mon, 08 Mar 2010)
@@ -34,7 +34,7 @@
         e <<
             errinfo_api_function("failed_api_function") <<
             errinfo_at_line(42) <<
- errinfo_errno(errno) <<
+ errinfo_errno(0) <<
             errinfo_file_handle(weak_ptr<FILE>()) <<
             errinfo_file_name("filename.txt") <<
             errinfo_file_open_mode("rb");

Modified: branches/release/libs/exception/test/error_info_test.cpp
==============================================================================
--- branches/release/libs/exception/test/error_info_test.cpp (original)
+++ branches/release/libs/exception/test/error_info_test.cpp 2010-03-08 03:18:25 EST (Mon, 08 Mar 2010)
@@ -5,6 +5,7 @@
 
 #include <boost/exception/get_error_info.hpp>
 #include <boost/exception/info_tuple.hpp>
+#include <boost/exception_ptr.hpp>
 #include <boost/detail/lightweight_test.hpp>
 #include <boost/detail/workaround.hpp>
 
@@ -302,7 +303,7 @@
     }
 
 void
-test_lifetime()
+test_lifetime1()
     {
     int count=0;
     try
@@ -323,6 +324,19 @@
     BOOST_TEST(!count);
     }
 
+void
+test_lifetime2()
+ {
+ int count=0;
+ {
+ boost::exception_ptr ep;
+ test_exception e; e<<test_7(user_data(count));
+ ep=boost::copy_exception(e);
+ BOOST_TEST(count>0);
+ }
+ BOOST_TEST(!count);
+ }
+
 bool
 is_const( int const * )
     {
@@ -354,7 +368,8 @@
     test_basic_throw_catch();
     test_catch_add_info();
     test_add_tuple();
- test_lifetime();
+ test_lifetime1();
+ test_lifetime2();
     test_const();
     return boost::report_errors();
     }

Added: branches/release/libs/exception/test/exception_ptr_test.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/exception/test/exception_ptr_test.cpp 2010-03-08 03:18:25 EST (Mon, 08 Mar 2010)
@@ -0,0 +1,112 @@
+//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)
+
+#include <boost/exception_ptr.hpp>
+#include <boost/exception/info.hpp>
+#include <boost/exception/get_error_info.hpp>
+#include <boost/exception/diagnostic_information.hpp>
+#include <boost/function.hpp>
+#include <boost/bind.hpp>
+#include <boost/thread.hpp>
+#include <boost/detail/lightweight_test.hpp>
+#include <iostream>
+
+class thread_handle;
+boost::shared_ptr<thread_handle> create_thread( boost::function<void()> const & f );
+void join( thread_handle & t );
+
+class
+thread_handle
+ {
+ thread_handle( thread_handle const & );
+ thread_handle & operator=( thread_handle const & );
+
+ boost::exception_ptr err_;
+ boost::thread t_;
+
+ static
+ void
+ thread_wrapper( boost::function<void()> const & f, boost::exception_ptr & ep )
+ {
+ BOOST_ASSERT(!ep);
+ try
+ {
+ f();
+ }
+ catch(...)
+ {
+ ep = boost::current_exception();
+ }
+ }
+
+ explicit
+ thread_handle( boost::function<void()> const & f ):
+ t_(boost::bind(thread_wrapper,f,err_))
+ {
+ }
+
+ friend boost::shared_ptr<thread_handle> create_thread( boost::function<void()> const & f );
+ friend void join( thread_handle & t );
+ };
+
+boost::shared_ptr<thread_handle>
+create_thread( boost::function<void()> const & f )
+ {
+ boost::shared_ptr<thread_handle> t( new thread_handle(f) );
+ return t;
+ }
+
+void
+join( thread_handle & t )
+ {
+ t.t_.join();
+ if( t.err_ )
+ rethrow_exception(t.err_);
+ }
+
+struct exc: boost::exception, std::exception { };
+typedef boost::error_info<struct answer_,int> answer;
+
+void
+thread_func()
+ {
+ BOOST_THROW_EXCEPTION(exc() << answer(42));
+ }
+
+void
+check( boost::shared_ptr<thread_handle> const & t )
+ {
+ try
+ {
+ join(*t);
+ }
+ catch(
+ exc & e )
+ {
+ int const * a = boost::get_error_info<answer>(e);
+ BOOST_TEST(a && *a==42);
+ }
+ }
+
+int
+main()
+ {
+ try
+ {
+ std::vector< boost::shared_ptr<thread_handle> > threads;
+ std::generate_n(std::inserter(threads,threads.end()),256,boost::bind(create_thread,thread_func));
+ std::for_each(threads.begin(),threads.end(),check);
+ return boost::report_errors();
+ }
+ catch(
+ ... )
+ {
+ std::cerr <<
+ "Caught unexpected exception.\n"
+ "Output from current_exception_diagnostic_information:\n" <<
+ boost::current_exception_diagnostic_information() << std::endl;
+ return 42;
+ }
+ }

Modified: branches/release/libs/exception/test/is_output_streamable_test.cpp
==============================================================================
--- branches/release/libs/exception/test/is_output_streamable_test.cpp (original)
+++ branches/release/libs/exception/test/is_output_streamable_test.cpp 2010-03-08 03:18:25 EST (Mon, 08 Mar 2010)
@@ -4,7 +4,6 @@
 //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 
 #include <boost/exception/detail/is_output_streamable.hpp>
-#include <boost/detail/lightweight_test.hpp>
 
 namespace
 n1
@@ -31,11 +30,20 @@
         }
     }
 
+template <bool Test>
+struct test;
+
+template <>
+struct
+test<true>
+ {
+ };
+
 int
 main()
     {
- BOOST_TEST( !boost::is_output_streamable<n1::c1>::value );
- BOOST_TEST( boost::is_output_streamable<n2::c2>::value );
- BOOST_TEST( boost::is_output_streamable<int>::value );
- return boost::report_errors();
+ test<!boost::is_output_streamable<n1::c1>::value>();
+ test<boost::is_output_streamable<n2::c2>::value>();
+ test<boost::is_output_streamable<int>::value>();
+ return 0;
     }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk