2008-03-04 01:41:17 +00:00
|
|
|
//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
|
|
|
|
|
2008-06-11 19:20:27 +00:00
|
|
|
#include <boost/exception/exception.hpp>
|
2008-03-04 01:41:17 +00:00
|
|
|
|
|
|
|
namespace
|
|
|
|
boost
|
2008-04-08 21:29:37 +00:00
|
|
|
{
|
|
|
|
namespace
|
|
|
|
exception_detail
|
|
|
|
{
|
2008-08-29 19:27:38 +00:00
|
|
|
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()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-08-28 23:49:55 +00:00
|
|
|
inline
|
|
|
|
void
|
|
|
|
copy_boost_exception( exception * a, exception const * b )
|
|
|
|
{
|
|
|
|
*a = *b;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
void
|
|
|
|
copy_boost_exception( void *, void const * )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-04-08 21:29:37 +00:00
|
|
|
template <class T>
|
|
|
|
class
|
|
|
|
clone_impl:
|
|
|
|
public T,
|
2008-08-29 19:27:38 +00:00
|
|
|
public clone_base
|
2008-04-08 21:29:37 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
explicit
|
|
|
|
clone_impl( T const & x ):
|
|
|
|
T(x)
|
|
|
|
{
|
2008-08-28 23:49:55 +00:00
|
|
|
copy_boost_exception(this,&x);
|
2008-04-08 21:29:37 +00:00
|
|
|
}
|
|
|
|
|
2008-08-29 04:56:02 +00:00
|
|
|
~clone_impl() throw()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-04-08 21:29:37 +00:00
|
|
|
private:
|
|
|
|
|
2008-08-29 19:27:38 +00:00
|
|
|
clone_base const *
|
2008-04-08 21:29:37 +00:00
|
|
|
clone() const
|
|
|
|
{
|
2008-08-29 19:27:38 +00:00
|
|
|
return new clone_impl(*this);
|
2008-04-08 21:29:37 +00:00
|
|
|
}
|
2008-08-29 04:56:02 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
rethrow() const
|
|
|
|
{
|
|
|
|
throw *this;
|
|
|
|
}
|
|
|
|
};
|
2008-04-08 21:29:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class T>
|
2008-07-09 00:18:09 +00:00
|
|
|
inline
|
2008-04-08 21:29:37 +00:00
|
|
|
exception_detail::clone_impl<T>
|
2008-04-15 18:24:46 +00:00
|
|
|
enable_current_exception( T const & x )
|
2008-04-08 21:29:37 +00:00
|
|
|
{
|
|
|
|
return exception_detail::clone_impl<T>(x);
|
|
|
|
}
|
|
|
|
}
|
2008-03-04 01:41:17 +00:00
|
|
|
|
|
|
|
#endif
|