mirror of
https://github.com/boostorg/exception.git
synced 2025-07-13 04:26:44 +02:00
Suppressing warnings. Please report any problems (may have broken something!)
[SVN r58072]
This commit is contained in:
@ -6,6 +6,10 @@
|
||||
#ifndef UUID_316FDA946C0D11DEA9CBAE5255D89593
|
||||
#define UUID_316FDA946C0D11DEA9CBAE5255D89593
|
||||
|
||||
#if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#include <boost/exception/diagnostic_information.hpp>
|
||||
#include <boost/exception/error_info.hpp>
|
||||
#include <boost/exception/exception.hpp>
|
||||
|
@ -6,6 +6,10 @@
|
||||
#ifndef UUID_7E83C166200811DE885E826156D89593
|
||||
#define UUID_7E83C166200811DE885E826156D89593
|
||||
|
||||
#if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
namespace
|
||||
boost
|
||||
{
|
||||
|
@ -6,9 +6,7 @@
|
||||
#ifndef UUID_61531AB0680611DEADD5846855D89593
|
||||
#define UUID_61531AB0680611DEADD5846855D89593
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#if defined(_MSC_VER)
|
||||
#define BOOST_ATTRIBUTE_NORETURN __declspec(noreturn)
|
||||
#elif defined(__GNUC__)
|
||||
#define BOOST_ATTRIBUTE_NORETURN __attribute__((noreturn))
|
||||
|
@ -6,6 +6,10 @@
|
||||
#ifndef UUID_CE6983AC753411DDA764247956D89593
|
||||
#define UUID_CE6983AC753411DDA764247956D89593
|
||||
|
||||
#if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace
|
||||
@ -24,13 +28,16 @@ boost
|
||||
|
||||
protected:
|
||||
|
||||
virtual
|
||||
~error_info_base() throw()
|
||||
{
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4512) //assignment operator could not be generated
|
||||
#endif
|
||||
template <class Tag,class T>
|
||||
class
|
||||
error_info:
|
||||
@ -62,6 +69,9 @@ boost
|
||||
|
||||
value_type value_;
|
||||
};
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
469
include/boost/exception/detail/exception_ptr.hpp
Normal file
469
include/boost/exception/detail/exception_ptr.hpp
Normal file
@ -0,0 +1,469 @@
|
||||
//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)
|
||||
|
||||
#ifndef UUID_618474C2DE1511DEB74A388C56D89593
|
||||
#define UUID_618474C2DE1511DEB74A388C56D89593
|
||||
|
||||
#if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#ifdef BOOST_NO_EXCEPTIONS
|
||||
#error This header requires exception handling to be enabled.
|
||||
#endif
|
||||
#include <boost/exception/exception.hpp>
|
||||
#include <boost/exception/info.hpp>
|
||||
#include <boost/exception/diagnostic_information.hpp>
|
||||
#include <boost/exception/detail/type_info.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <stdexcept>
|
||||
#include <new>
|
||||
#include <ios>
|
||||
|
||||
namespace
|
||||
boost
|
||||
{
|
||||
#ifndef BOOST_NO_RTTI
|
||||
typedef error_info<struct tag_original_exception_type,std::type_info const *> original_exception_type;
|
||||
|
||||
inline
|
||||
std::string
|
||||
to_string( original_exception_type const & x )
|
||||
{
|
||||
return x.value()->name();
|
||||
}
|
||||
#endif
|
||||
|
||||
class exception_ptr;
|
||||
exception_ptr current_exception();
|
||||
void rethrow_exception( exception_ptr const & );
|
||||
|
||||
class
|
||||
exception_ptr:
|
||||
public exception_detail::exception_ptr_base
|
||||
{
|
||||
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()
|
||||
{
|
||||
}
|
||||
|
||||
operator unspecified_bool_type() const
|
||||
{
|
||||
return _empty() ? 0 : &exception_ptr::bad_alloc_;
|
||||
}
|
||||
|
||||
friend
|
||||
bool
|
||||
operator==( exception_ptr const & a, exception_ptr const & b )
|
||||
{
|
||||
return a.c_==b.c_ && a.bad_alloc_==b.bad_alloc_;
|
||||
}
|
||||
|
||||
friend
|
||||
bool
|
||||
operator!=( exception_ptr const & a, exception_ptr const & b )
|
||||
{
|
||||
return !(a==b);
|
||||
}
|
||||
};
|
||||
|
||||
class
|
||||
unknown_exception:
|
||||
public exception,
|
||||
public std::exception,
|
||||
public exception_detail::clone_base
|
||||
{
|
||||
public:
|
||||
|
||||
unknown_exception()
|
||||
{
|
||||
}
|
||||
|
||||
explicit
|
||||
unknown_exception( std::exception const & e )
|
||||
{
|
||||
add_original_type(e);
|
||||
}
|
||||
|
||||
explicit
|
||||
unknown_exception( boost::exception const & e ):
|
||||
boost::exception(e)
|
||||
{
|
||||
add_original_type(e);
|
||||
}
|
||||
|
||||
~unknown_exception() throw()
|
||||
{
|
||||
}
|
||||
|
||||
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 )
|
||||
{
|
||||
#ifndef BOOST_NO_RTTI
|
||||
(*this) << original_exception_type(&typeid(e));
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
namespace
|
||||
exception_detail
|
||||
{
|
||||
template <class T>
|
||||
class
|
||||
current_exception_std_exception_wrapper:
|
||||
public T,
|
||||
public boost::exception,
|
||||
public clone_base
|
||||
{
|
||||
public:
|
||||
|
||||
explicit
|
||||
current_exception_std_exception_wrapper( T const & e1 ):
|
||||
T(e1)
|
||||
{
|
||||
add_original_type(e1);
|
||||
}
|
||||
|
||||
current_exception_std_exception_wrapper( T const & e1, boost::exception const & e2 ):
|
||||
T(e1),
|
||||
boost::exception(e2)
|
||||
{
|
||||
add_original_type(e1);
|
||||
}
|
||||
|
||||
~current_exception_std_exception_wrapper() throw()
|
||||
{
|
||||
}
|
||||
|
||||
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 )
|
||||
{
|
||||
#ifndef BOOST_NO_RTTI
|
||||
(*this) << original_exception_type(&typeid(e));
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef BOOST_NO_RTTI
|
||||
template <class T>
|
||||
exception const *
|
||||
get_boost_exception( T const * )
|
||||
{
|
||||
try
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch(
|
||||
exception & x )
|
||||
{
|
||||
return &x;
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#else
|
||||
template <class T>
|
||||
exception const *
|
||||
get_boost_exception( T const * x )
|
||||
{
|
||||
return dynamic_cast<exception const *>(x);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
shared_ptr<clone_base const>
|
||||
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));
|
||||
else
|
||||
return shared_ptr<current_exception_std_exception_wrapper<T> const>(new current_exception_std_exception_wrapper<T>(e1));
|
||||
}
|
||||
|
||||
inline
|
||||
shared_ptr<clone_base const>
|
||||
current_exception_unknown_exception()
|
||||
{
|
||||
return shared_ptr<unknown_exception const>(new unknown_exception());
|
||||
}
|
||||
|
||||
inline
|
||||
shared_ptr<clone_base const>
|
||||
current_exception_unknown_boost_exception( boost::exception const & e )
|
||||
{
|
||||
return shared_ptr<unknown_exception const>(new unknown_exception(e));
|
||||
}
|
||||
|
||||
inline
|
||||
shared_ptr<clone_base const>
|
||||
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));
|
||||
}
|
||||
|
||||
inline
|
||||
shared_ptr<clone_base const>
|
||||
current_exception_impl()
|
||||
{
|
||||
try
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch(
|
||||
exception_detail::clone_base & e )
|
||||
{
|
||||
return shared_ptr<exception_detail::clone_base const>(e.clone());
|
||||
}
|
||||
catch(
|
||||
std::domain_error & e )
|
||||
{
|
||||
return exception_detail::current_exception_std_exception(e);
|
||||
}
|
||||
catch(
|
||||
std::invalid_argument & e )
|
||||
{
|
||||
return exception_detail::current_exception_std_exception(e);
|
||||
}
|
||||
catch(
|
||||
std::length_error & e )
|
||||
{
|
||||
return exception_detail::current_exception_std_exception(e);
|
||||
}
|
||||
catch(
|
||||
std::out_of_range & e )
|
||||
{
|
||||
return exception_detail::current_exception_std_exception(e);
|
||||
}
|
||||
catch(
|
||||
std::logic_error & e )
|
||||
{
|
||||
return exception_detail::current_exception_std_exception(e);
|
||||
}
|
||||
catch(
|
||||
std::range_error & e )
|
||||
{
|
||||
return exception_detail::current_exception_std_exception(e);
|
||||
}
|
||||
catch(
|
||||
std::overflow_error & e )
|
||||
{
|
||||
return exception_detail::current_exception_std_exception(e);
|
||||
}
|
||||
catch(
|
||||
std::underflow_error & e )
|
||||
{
|
||||
return exception_detail::current_exception_std_exception(e);
|
||||
}
|
||||
catch(
|
||||
std::ios_base::failure & e )
|
||||
{
|
||||
return exception_detail::current_exception_std_exception(e);
|
||||
}
|
||||
catch(
|
||||
std::runtime_error & e )
|
||||
{
|
||||
return exception_detail::current_exception_std_exception(e);
|
||||
}
|
||||
catch(
|
||||
std::bad_alloc & e )
|
||||
{
|
||||
return exception_detail::current_exception_std_exception(e);
|
||||
}
|
||||
#ifndef BOOST_NO_TYPEID
|
||||
catch(
|
||||
std::bad_cast & e )
|
||||
{
|
||||
return exception_detail::current_exception_std_exception(e);
|
||||
}
|
||||
catch(
|
||||
std::bad_typeid & e )
|
||||
{
|
||||
return exception_detail::current_exception_std_exception(e);
|
||||
}
|
||||
#endif
|
||||
catch(
|
||||
std::bad_exception & e )
|
||||
{
|
||||
return exception_detail::current_exception_std_exception(e);
|
||||
}
|
||||
catch(
|
||||
std::exception & e )
|
||||
{
|
||||
return exception_detail::current_exception_unknown_std_exception(e);
|
||||
}
|
||||
catch(
|
||||
boost::exception & e )
|
||||
{
|
||||
return exception_detail::current_exception_unknown_boost_exception(e);
|
||||
}
|
||||
catch(
|
||||
... )
|
||||
{
|
||||
return exception_detail::current_exception_unknown_exception();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
exception_ptr
|
||||
current_exception()
|
||||
{
|
||||
try
|
||||
{
|
||||
return exception_ptr(exception_detail::current_exception_impl());
|
||||
}
|
||||
catch(
|
||||
std::bad_alloc & )
|
||||
{
|
||||
}
|
||||
catch(
|
||||
... )
|
||||
{
|
||||
try
|
||||
{
|
||||
return exception_ptr(exception_detail::current_exception_std_exception(std::bad_exception()));
|
||||
}
|
||||
catch(
|
||||
std::bad_alloc & )
|
||||
{
|
||||
}
|
||||
catch(
|
||||
... )
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
rethrow_exception( exception_ptr const & p )
|
||||
{
|
||||
p._rethrow();
|
||||
}
|
||||
|
||||
inline
|
||||
std::string
|
||||
to_string( exception_ptr const & p )
|
||||
{
|
||||
std::string s='\n'+diagnostic_information(p);
|
||||
std::string padding(" ");
|
||||
std::string r;
|
||||
bool f=false;
|
||||
for( std::string::const_iterator i=s.begin(),e=s.end(); i!=e; ++i )
|
||||
{
|
||||
if( f )
|
||||
r+=padding;
|
||||
char c=*i;
|
||||
r+=c;
|
||||
f=(c=='\n');
|
||||
}
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -6,6 +6,10 @@
|
||||
#ifndef UUID_DC4208C6417811DEBF11E1EC55D89593
|
||||
#define UUID_DC4208C6417811DEBF11E1EC55D89593
|
||||
|
||||
#if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
namespace
|
||||
boost
|
||||
{
|
||||
@ -22,7 +26,6 @@ boost
|
||||
|
||||
protected:
|
||||
|
||||
virtual
|
||||
~exception_ptr_base() throw()
|
||||
{
|
||||
}
|
||||
|
@ -6,6 +6,10 @@
|
||||
#ifndef UUID_898984B4076411DD973EDFA055D89593
|
||||
#define UUID_898984B4076411DD973EDFA055D89593
|
||||
|
||||
#if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#include <ostream>
|
||||
|
||||
namespace
|
||||
|
@ -6,6 +6,10 @@
|
||||
#ifndef UUID_6F463AC838DF11DDA3E6909F56D89593
|
||||
#define UUID_6F463AC838DF11DDA3E6909F56D89593
|
||||
|
||||
#if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#include <boost/exception/detail/type_info.hpp>
|
||||
#include <iomanip>
|
||||
#include <ios>
|
||||
|
@ -6,8 +6,13 @@
|
||||
#ifndef UUID_C3E1741C754311DDB2834CCA55D89593
|
||||
#define UUID_C3E1741C754311DDB2834CCA55D89593
|
||||
|
||||
#if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#include <boost/detail/sp_typeinfo.hpp>
|
||||
#include <boost/current_function.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
namespace
|
||||
boost
|
||||
|
@ -6,10 +6,15 @@
|
||||
#ifndef UUID_0552D49838DD11DD90146B8956D89593
|
||||
#define UUID_0552D49838DD11DD90146B8956D89593
|
||||
|
||||
#if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/exception/get_error_info.hpp>
|
||||
#include <boost/exception/detail/exception_ptr_base.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <exception>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
@ -6,10 +6,19 @@
|
||||
#ifndef UUID_F0EE17BE6C1211DE87FF459155D89593
|
||||
#define UUID_F0EE17BE6C1211DE87FF459155D89593
|
||||
|
||||
#if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#include "boost/exception/info.hpp"
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4996) //'strerror': This function or variable may be unsafe
|
||||
#endif
|
||||
|
||||
namespace
|
||||
boost
|
||||
{
|
||||
@ -32,4 +41,8 @@ boost
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -6,6 +6,10 @@
|
||||
#ifndef UUID_274DA366004E11DCB1DDFE2E56D89593
|
||||
#define UUID_274DA366004E11DCB1DDFE2E56D89593
|
||||
|
||||
#if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
namespace
|
||||
boost
|
||||
{
|
||||
@ -151,7 +155,6 @@ boost
|
||||
|
||||
protected:
|
||||
|
||||
virtual
|
||||
~error_info_container() throw()
|
||||
{
|
||||
}
|
||||
@ -349,6 +352,10 @@ boost
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4512) //assignment operator could not be generated
|
||||
#endif
|
||||
template <class T>
|
||||
class
|
||||
clone_impl:
|
||||
@ -382,6 +389,9 @@ boost
|
||||
throw*this;
|
||||
}
|
||||
};
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
|
@ -6,6 +6,10 @@
|
||||
#ifndef UUID_1A590226753311DD9E4CCF6156D89593
|
||||
#define UUID_1A590226753311DD9E4CCF6156D89593
|
||||
|
||||
#if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#include <boost/exception/exception.hpp>
|
||||
#include <boost/exception/detail/error_info_impl.hpp>
|
||||
#include <boost/exception/detail/type_info.hpp>
|
||||
|
@ -6,10 +6,15 @@
|
||||
#ifndef UUID_8D22C4CA9CC811DCAA9133D256D89593
|
||||
#define UUID_8D22C4CA9CC811DCAA9133D256D89593
|
||||
|
||||
#if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#include <boost/exception/exception.hpp>
|
||||
#include <boost/exception/to_string_stub.hpp>
|
||||
#include <boost/exception/detail/error_info_impl.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <map>
|
||||
|
||||
namespace
|
||||
@ -146,8 +151,8 @@ boost
|
||||
{
|
||||
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;
|
||||
if( !(c=x.data_.get()) )
|
||||
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;
|
||||
|
@ -6,6 +6,10 @@
|
||||
#ifndef UUID_63EE924290FB11DC87BB856555D89593
|
||||
#define UUID_63EE924290FB11DC87BB856555D89593
|
||||
|
||||
#if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#include <boost/exception/info.hpp>
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
|
||||
|
@ -6,6 +6,10 @@
|
||||
#ifndef UUID_7E48761AD92811DC9011477D56D89593
|
||||
#define UUID_7E48761AD92811DC9011477D56D89593
|
||||
|
||||
#if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/exception/detail/is_output_streamable.hpp>
|
||||
#include <sstream>
|
||||
|
@ -6,6 +6,10 @@
|
||||
#ifndef UUID_E788439ED9F011DCB181F25B55D89593
|
||||
#define UUID_E788439ED9F011DCB181F25B55D89593
|
||||
|
||||
#if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#include <boost/exception/to_string.hpp>
|
||||
#include <boost/exception/detail/object_hex_dump.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
|
@ -6,460 +6,6 @@
|
||||
#ifndef UUID_FA5836A2CADA11DC8CD47C8555D89593
|
||||
#define UUID_FA5836A2CADA11DC8CD47C8555D89593
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#ifdef BOOST_NO_EXCEPTIONS
|
||||
#error This header requires exception handling to be enabled.
|
||||
#endif
|
||||
#include <boost/exception/exception.hpp>
|
||||
#include <boost/exception/info.hpp>
|
||||
#include <boost/exception/diagnostic_information.hpp>
|
||||
#include <boost/exception/detail/type_info.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <stdexcept>
|
||||
#include <new>
|
||||
#include <ios>
|
||||
|
||||
namespace
|
||||
boost
|
||||
{
|
||||
#ifndef BOOST_NO_RTTI
|
||||
typedef error_info<struct tag_original_exception_type,std::type_info const *> original_exception_type;
|
||||
|
||||
inline
|
||||
std::string
|
||||
to_string( original_exception_type const & x )
|
||||
{
|
||||
return x.value()->name();
|
||||
}
|
||||
#endif
|
||||
|
||||
class exception_ptr;
|
||||
exception_ptr current_exception();
|
||||
void rethrow_exception( exception_ptr const & );
|
||||
|
||||
class
|
||||
exception_ptr:
|
||||
public exception_detail::exception_ptr_base
|
||||
{
|
||||
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()
|
||||
{
|
||||
}
|
||||
|
||||
operator unspecified_bool_type() const
|
||||
{
|
||||
return _empty() ? 0 : &exception_ptr::bad_alloc_;
|
||||
}
|
||||
|
||||
friend
|
||||
bool
|
||||
operator==( exception_ptr const & a, exception_ptr const & b )
|
||||
{
|
||||
return a.c_==b.c_ && a.bad_alloc_==b.bad_alloc_;
|
||||
}
|
||||
|
||||
friend
|
||||
bool
|
||||
operator!=( exception_ptr const & a, exception_ptr const & b )
|
||||
{
|
||||
return !(a==b);
|
||||
}
|
||||
};
|
||||
|
||||
class
|
||||
unknown_exception:
|
||||
public exception,
|
||||
public std::exception,
|
||||
public exception_detail::clone_base
|
||||
{
|
||||
public:
|
||||
|
||||
unknown_exception()
|
||||
{
|
||||
}
|
||||
|
||||
explicit
|
||||
unknown_exception( std::exception const & e )
|
||||
{
|
||||
add_original_type(e);
|
||||
}
|
||||
|
||||
explicit
|
||||
unknown_exception( boost::exception const & e ):
|
||||
boost::exception(e)
|
||||
{
|
||||
add_original_type(e);
|
||||
}
|
||||
|
||||
~unknown_exception() throw()
|
||||
{
|
||||
}
|
||||
|
||||
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 )
|
||||
{
|
||||
#ifndef BOOST_NO_RTTI
|
||||
(*this) << original_exception_type(&typeid(e));
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
namespace
|
||||
exception_detail
|
||||
{
|
||||
template <class T>
|
||||
class
|
||||
current_exception_std_exception_wrapper:
|
||||
public T,
|
||||
public boost::exception,
|
||||
public clone_base
|
||||
{
|
||||
public:
|
||||
|
||||
explicit
|
||||
current_exception_std_exception_wrapper( T const & e1 ):
|
||||
T(e1)
|
||||
{
|
||||
add_original_type(e1);
|
||||
}
|
||||
|
||||
current_exception_std_exception_wrapper( T const & e1, boost::exception const & e2 ):
|
||||
T(e1),
|
||||
boost::exception(e2)
|
||||
{
|
||||
add_original_type(e1);
|
||||
}
|
||||
|
||||
~current_exception_std_exception_wrapper() throw()
|
||||
{
|
||||
}
|
||||
|
||||
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 )
|
||||
{
|
||||
#ifndef BOOST_NO_RTTI
|
||||
(*this) << original_exception_type(&typeid(e));
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef BOOST_NO_RTTI
|
||||
template <class T>
|
||||
exception const *
|
||||
get_boost_exception( T const * )
|
||||
{
|
||||
try
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch(
|
||||
exception & x )
|
||||
{
|
||||
return &x;
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#else
|
||||
template <class T>
|
||||
exception const *
|
||||
get_boost_exception( T const * x )
|
||||
{
|
||||
return dynamic_cast<exception const *>(x);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
shared_ptr<clone_base const>
|
||||
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));
|
||||
else
|
||||
return shared_ptr<current_exception_std_exception_wrapper<T> const>(new current_exception_std_exception_wrapper<T>(e1));
|
||||
}
|
||||
|
||||
inline
|
||||
shared_ptr<clone_base const>
|
||||
current_exception_unknown_exception()
|
||||
{
|
||||
return shared_ptr<unknown_exception const>(new unknown_exception());
|
||||
}
|
||||
|
||||
inline
|
||||
shared_ptr<clone_base const>
|
||||
current_exception_unknown_boost_exception( boost::exception const & e )
|
||||
{
|
||||
return shared_ptr<unknown_exception const>(new unknown_exception(e));
|
||||
}
|
||||
|
||||
inline
|
||||
shared_ptr<clone_base const>
|
||||
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));
|
||||
}
|
||||
|
||||
inline
|
||||
shared_ptr<clone_base const>
|
||||
current_exception_impl()
|
||||
{
|
||||
try
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch(
|
||||
exception_detail::clone_base & e )
|
||||
{
|
||||
return shared_ptr<exception_detail::clone_base const>(e.clone());
|
||||
}
|
||||
catch(
|
||||
std::domain_error & e )
|
||||
{
|
||||
return exception_detail::current_exception_std_exception(e);
|
||||
}
|
||||
catch(
|
||||
std::invalid_argument & e )
|
||||
{
|
||||
return exception_detail::current_exception_std_exception(e);
|
||||
}
|
||||
catch(
|
||||
std::length_error & e )
|
||||
{
|
||||
return exception_detail::current_exception_std_exception(e);
|
||||
}
|
||||
catch(
|
||||
std::out_of_range & e )
|
||||
{
|
||||
return exception_detail::current_exception_std_exception(e);
|
||||
}
|
||||
catch(
|
||||
std::logic_error & e )
|
||||
{
|
||||
return exception_detail::current_exception_std_exception(e);
|
||||
}
|
||||
catch(
|
||||
std::range_error & e )
|
||||
{
|
||||
return exception_detail::current_exception_std_exception(e);
|
||||
}
|
||||
catch(
|
||||
std::overflow_error & e )
|
||||
{
|
||||
return exception_detail::current_exception_std_exception(e);
|
||||
}
|
||||
catch(
|
||||
std::underflow_error & e )
|
||||
{
|
||||
return exception_detail::current_exception_std_exception(e);
|
||||
}
|
||||
catch(
|
||||
std::ios_base::failure & e )
|
||||
{
|
||||
return exception_detail::current_exception_std_exception(e);
|
||||
}
|
||||
catch(
|
||||
std::runtime_error & e )
|
||||
{
|
||||
return exception_detail::current_exception_std_exception(e);
|
||||
}
|
||||
catch(
|
||||
std::bad_alloc & e )
|
||||
{
|
||||
return exception_detail::current_exception_std_exception(e);
|
||||
}
|
||||
#ifndef BOOST_NO_TYPEID
|
||||
catch(
|
||||
std::bad_cast & e )
|
||||
{
|
||||
return exception_detail::current_exception_std_exception(e);
|
||||
}
|
||||
catch(
|
||||
std::bad_typeid & e )
|
||||
{
|
||||
return exception_detail::current_exception_std_exception(e);
|
||||
}
|
||||
#endif
|
||||
catch(
|
||||
std::bad_exception & e )
|
||||
{
|
||||
return exception_detail::current_exception_std_exception(e);
|
||||
}
|
||||
catch(
|
||||
std::exception & e )
|
||||
{
|
||||
return exception_detail::current_exception_unknown_std_exception(e);
|
||||
}
|
||||
catch(
|
||||
boost::exception & e )
|
||||
{
|
||||
return exception_detail::current_exception_unknown_boost_exception(e);
|
||||
}
|
||||
catch(
|
||||
... )
|
||||
{
|
||||
return exception_detail::current_exception_unknown_exception();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
exception_ptr
|
||||
current_exception()
|
||||
{
|
||||
try
|
||||
{
|
||||
return exception_ptr(exception_detail::current_exception_impl());
|
||||
}
|
||||
catch(
|
||||
std::bad_alloc & )
|
||||
{
|
||||
}
|
||||
catch(
|
||||
... )
|
||||
{
|
||||
try
|
||||
{
|
||||
return exception_ptr(exception_detail::current_exception_std_exception(std::bad_exception()));
|
||||
}
|
||||
catch(
|
||||
std::bad_alloc & )
|
||||
{
|
||||
}
|
||||
catch(
|
||||
... )
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
rethrow_exception( exception_ptr const & p )
|
||||
{
|
||||
p._rethrow();
|
||||
}
|
||||
|
||||
inline
|
||||
std::string
|
||||
to_string( exception_ptr const & p )
|
||||
{
|
||||
std::string s='\n'+diagnostic_information(p);
|
||||
std::string padding(" ");
|
||||
std::string r;
|
||||
bool f=false;
|
||||
for( std::string::const_iterator i=s.begin(),e=s.end(); i!=e; ++i )
|
||||
{
|
||||
if( f )
|
||||
r+=padding;
|
||||
char c=*i;
|
||||
r+=c;
|
||||
f=(c=='\n');
|
||||
}
|
||||
return r;
|
||||
}
|
||||
}
|
||||
#include <boost/exception/detail/exception_ptr.hpp>
|
||||
|
||||
#endif
|
||||
|
@ -6,6 +6,11 @@
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(disable:4702) //unreachable code
|
||||
#endif
|
||||
|
||||
class my_exception: public std::exception { };
|
||||
|
||||
int
|
||||
|
@ -7,6 +7,11 @@
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(disable:4702) //unreachable code
|
||||
#endif
|
||||
|
||||
class my_exception: public std::exception { };
|
||||
|
||||
int
|
||||
|
@ -7,7 +7,11 @@
|
||||
|
||||
import testing ;
|
||||
|
||||
project : requirements <exception-handling>on ;
|
||||
project
|
||||
: requirements
|
||||
<exception-handling>on
|
||||
<warnings>all
|
||||
;
|
||||
|
||||
#to_string
|
||||
|
||||
@ -45,7 +49,6 @@ compile-fail error_info_const_fail.cpp ;
|
||||
compile exception_ptr_hpp_test.cpp ;
|
||||
compile diagnostic_information_hpp_test.cpp ;
|
||||
compile error_info_hpp_test.cpp ;
|
||||
compile exception_hpp_test.cpp ;
|
||||
compile get_error_info_hpp_test.cpp ;
|
||||
compile info_hpp_test.cpp ;
|
||||
compile info_tuple_hpp_test.cpp ;
|
||||
|
@ -10,8 +10,9 @@
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <string>
|
||||
|
||||
#if BOOST_WORKAROUND(__CODEGEARC__, BOOST_TESTED_AT(0x610))
|
||||
struct my_tag {};
|
||||
#include <boost/config.hpp>
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(disable:4512) //assignment operator could not be generated
|
||||
#endif
|
||||
|
||||
typedef boost::error_info<struct my_tag,int> my_info;
|
||||
|
@ -17,6 +17,11 @@
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <exception>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(disable:4702) //unreachable code
|
||||
#endif
|
||||
|
||||
struct
|
||||
test_exception:
|
||||
virtual boost::exception,
|
||||
@ -43,7 +48,7 @@ main()
|
||||
#else
|
||||
BOOST_THROW_EXCEPTION(e<<errinfo_type_info_name(typeid(int).name()));
|
||||
#endif
|
||||
BOOST_TEST(false);
|
||||
BOOST_ERROR("BOOST_THROW_EXCEPTION failed to throw.");
|
||||
}
|
||||
catch(
|
||||
boost::exception & e )
|
||||
|
@ -9,10 +9,6 @@
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <errno.h>
|
||||
|
||||
#if BOOST_WORKAROUND(__CODEGEARC__, BOOST_TESTED_AT(0x610))
|
||||
struct tag_errno {};
|
||||
#endif
|
||||
|
||||
typedef boost::error_info<struct tag_errno,int> info_errno;
|
||||
|
||||
class
|
||||
@ -28,7 +24,6 @@ main()
|
||||
{
|
||||
errno=1;
|
||||
throw my_exception() << info_errno(errno);
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
catch(
|
||||
my_exception & x )
|
||||
|
@ -8,6 +8,12 @@
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(disable:4702) //unreachable code
|
||||
#pragma warning(disable:4512) //assignment operator could not be generated
|
||||
#endif
|
||||
|
||||
struct throws_on_copy;
|
||||
struct non_printable { };
|
||||
|
||||
@ -35,16 +41,6 @@ user_data
|
||||
}
|
||||
};
|
||||
|
||||
#if BOOST_WORKAROUND(__CODEGEARC__, BOOST_TESTED_AT(0x610))
|
||||
struct tag_test_1 {};
|
||||
struct tag_test_2 {};
|
||||
struct tag_test_3 {};
|
||||
struct tag_test_4 {};
|
||||
struct tag_test_5 {};
|
||||
struct tag_test_6 {};
|
||||
struct tag_user_data {};
|
||||
#endif
|
||||
|
||||
typedef boost::error_info<struct tag_test_1,int> test_1;
|
||||
typedef boost::error_info<struct tag_test_2,unsigned int> test_2;
|
||||
typedef boost::error_info<struct tag_test_3,float> test_3;
|
||||
@ -318,7 +314,6 @@ test_lifetime()
|
||||
try
|
||||
{
|
||||
throw test_exception() << test_7(user_data(count));
|
||||
BOOST_TEST(false);
|
||||
}
|
||||
catch(
|
||||
boost::exception & x )
|
||||
|
@ -9,6 +9,11 @@
|
||||
#include <boost/exception_ptr.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(disable:4702) //unreachable code
|
||||
#endif
|
||||
|
||||
typedef boost::error_info<struct tag_test_int,int> test_data;
|
||||
|
||||
struct
|
||||
@ -30,7 +35,7 @@ boost_throw_exception_test()
|
||||
try
|
||||
{
|
||||
BOOST_THROW_EXCEPTION(exception1());
|
||||
BOOST_TEST(false);
|
||||
BOOST_ERROR("BOOST_THROW_EXCEPTION failed to throw.");
|
||||
}
|
||||
catch(
|
||||
boost::exception & x )
|
||||
@ -40,7 +45,7 @@ boost_throw_exception_test()
|
||||
int const * line=boost::get_error_info<boost::throw_line>(x);
|
||||
BOOST_TEST( file && *file );
|
||||
BOOST_TEST( function && *function );
|
||||
BOOST_TEST( line && *line==32 );
|
||||
BOOST_TEST( line && *line==37 );
|
||||
}
|
||||
catch(
|
||||
... )
|
||||
@ -50,7 +55,7 @@ boost_throw_exception_test()
|
||||
try
|
||||
{
|
||||
BOOST_THROW_EXCEPTION(exception2() << test_data(42));
|
||||
BOOST_TEST(false);
|
||||
BOOST_ERROR("BOOST_THROW_EXCEPTION failed to throw.");
|
||||
}
|
||||
catch(
|
||||
boost::exception & x )
|
||||
@ -61,7 +66,7 @@ boost_throw_exception_test()
|
||||
int const * data=boost::get_error_info<test_data>(x);
|
||||
BOOST_TEST( file && *file );
|
||||
BOOST_TEST( function && *function );
|
||||
BOOST_TEST( line && *line==52 );
|
||||
BOOST_TEST( line && *line==57 );
|
||||
BOOST_TEST( data && *data==42 );
|
||||
}
|
||||
catch(
|
||||
|
Reference in New Issue
Block a user