forked from boostorg/exception
decoupled boost/exception/exception.hpp from boost/exception/detail/type_info.hpp
diagnostic_information improvements documentation update [SVN r48469]
This commit is contained in:
@ -1,47 +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_B9A8291074CA11DD94BFC77156D89593
|
||||
#define UUID_B9A8291074CA11DD94BFC77156D89593
|
||||
|
||||
#include <boost/exception/exception.hpp>
|
||||
|
||||
namespace
|
||||
boost
|
||||
{
|
||||
namespace
|
||||
exception_detail
|
||||
{
|
||||
#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
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -12,10 +12,10 @@
|
||||
namespace
|
||||
boost
|
||||
{
|
||||
template <class ErrorInfoTag>
|
||||
template <class T>
|
||||
inline
|
||||
char const *
|
||||
error_info_value()
|
||||
type_name()
|
||||
{
|
||||
return BOOST_CURRENT_FUNCTION;
|
||||
}
|
||||
@ -23,40 +23,99 @@ boost
|
||||
namespace
|
||||
exception_detail
|
||||
{
|
||||
typedef detail::sp_typeinfo type_info_;
|
||||
|
||||
#ifdef BOOST_NO_TYPEID
|
||||
typedef type_info_ type_info_wrapper;
|
||||
#else
|
||||
struct
|
||||
type_info_wrapper
|
||||
type_info_
|
||||
{
|
||||
type_info_ const * type;
|
||||
detail::sp_typeinfo type_;
|
||||
char const * name_;
|
||||
|
||||
explicit
|
||||
type_info_wrapper( type_info_ const & t ):
|
||||
type(&t)
|
||||
type_info_( detail::sp_typeinfo type, char const * name ):
|
||||
type_(type),
|
||||
name_(name)
|
||||
{
|
||||
}
|
||||
|
||||
friend
|
||||
bool
|
||||
operator<( type_info_wrapper const & b ) const
|
||||
operator==( type_info_ const & a, type_info_ const & b )
|
||||
{
|
||||
return 0!=(type->before(*b.type));
|
||||
return a.type_==b.type_;
|
||||
}
|
||||
|
||||
friend
|
||||
bool
|
||||
operator!=( type_info_ const & a, type_info_ const & b )
|
||||
{
|
||||
return !(a==b);
|
||||
}
|
||||
|
||||
friend
|
||||
bool
|
||||
operator<( type_info_ const & a, type_info_ const & b )
|
||||
{
|
||||
return a.type_<b.type_;
|
||||
}
|
||||
|
||||
char const *
|
||||
name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
};
|
||||
#else
|
||||
struct
|
||||
type_info_
|
||||
{
|
||||
detail::sp_typeinfo const * type_;
|
||||
|
||||
explicit
|
||||
type_info_( detail::sp_typeinfo const & type ):
|
||||
type_(&type)
|
||||
{
|
||||
}
|
||||
|
||||
type_info_( detail::sp_typeinfo const & type, char const * ):
|
||||
type_(&type)
|
||||
{
|
||||
}
|
||||
|
||||
friend
|
||||
bool
|
||||
operator==( type_info_ const & a, type_info_ const & b )
|
||||
{
|
||||
return (*a.type_)==(*b.type_);
|
||||
}
|
||||
|
||||
friend
|
||||
bool
|
||||
operator!=( type_info_ const & a, type_info_ const & b )
|
||||
{
|
||||
return !(a==b);
|
||||
}
|
||||
|
||||
friend
|
||||
bool
|
||||
operator<( type_info_ const & a, type_info_ const & b )
|
||||
{
|
||||
return 0!=(a.type_->before(*b.type_));
|
||||
}
|
||||
|
||||
char const *
|
||||
name() const
|
||||
{
|
||||
return type_->name();
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
template <class ErrorInfoTag>
|
||||
inline
|
||||
char const *
|
||||
type_name()
|
||||
{
|
||||
return error_info_value<ErrorInfoTag>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define BOOST_EXCEPTION_STATIC_TYPEID(T) BOOST_SP_TYPEID(T)
|
||||
#define BOOST_EXCEPTION_STATIC_TYPEID(T) ::boost::exception_detail::type_info_(BOOST_SP_TYPEID(T),::boost::type_name<T>())
|
||||
|
||||
#ifndef BOOST_NO_RTTI
|
||||
#define BOOST_EXCEPTION_DYNAMIC_TYPEID(x) ::boost::exception_detail::type_info_(typeid(x))
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user