mirror of
https://github.com/boostorg/exception.git
synced 2025-07-20 16:02:06 +02:00
Fixing problems found by the vacpp test.
[SVN r59743]
This commit is contained in:
@ -20,8 +20,21 @@ boost
|
|||||||
namespace
|
namespace
|
||||||
to_string_detail
|
to_string_detail
|
||||||
{
|
{
|
||||||
template <class T,class CharT,class Traits>
|
struct
|
||||||
char operator<<( std::basic_ostream<CharT,Traits> &, T const & );
|
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>
|
template <class T,class CharT,class Traits>
|
||||||
struct
|
struct
|
||||||
|
@ -132,18 +132,6 @@ boost
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
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;
|
class exception;
|
||||||
|
|
||||||
template <class>
|
template <class>
|
||||||
@ -187,6 +175,18 @@ boost
|
|||||||
char const * get_diagnostic_information( exception const &, char const * );
|
char const * get_diagnostic_information( exception const &, char const * );
|
||||||
|
|
||||||
void copy_boost_exception( exception *, exception 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
|
class
|
||||||
@ -225,18 +225,18 @@ boost
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
template <class E>
|
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>
|
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>
|
template <class E>
|
||||||
friend E const & operator<<( E const &, throw_line const & );
|
friend E const & exception_detail::set_info( E const &, throw_line const & );
|
||||||
|
|
||||||
friend char const * exception_detail::get_diagnostic_information( exception const &, char const * );
|
|
||||||
|
|
||||||
template <class E,class Tag,class T>
|
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>
|
template <class>
|
||||||
friend struct exception_detail::get_info;
|
friend struct exception_detail::get_info;
|
||||||
@ -257,28 +257,32 @@ boost
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class E>
|
namespace
|
||||||
E const &
|
exception_detail
|
||||||
operator<<( E const & x, throw_function const & y )
|
|
||||||
{
|
{
|
||||||
x.throw_function_=y.v_;
|
template <class E>
|
||||||
return x;
|
E const &
|
||||||
}
|
set_info( E const & x, throw_function const & y )
|
||||||
|
{
|
||||||
|
x.throw_function_=y.v_;
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
template <class E>
|
template <class E>
|
||||||
E const &
|
E const &
|
||||||
operator<<( E const & x, throw_file const & y )
|
set_info( E const & x, throw_file const & y )
|
||||||
{
|
{
|
||||||
x.throw_file_=y.v_;
|
x.throw_file_=y.v_;
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class E>
|
template <class E>
|
||||||
E const &
|
E const &
|
||||||
operator<<( E const & x, throw_line const & y )
|
set_info( E const & x, throw_line const & y )
|
||||||
{
|
{
|
||||||
x.throw_line_=y.v_;
|
x.throw_line_=y.v_;
|
||||||
return x;
|
return x;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
@ -304,10 +308,10 @@ boost
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct large_size { char c[256]; };
|
struct large_size { char c[256]; };
|
||||||
large_size dispatch( exception * );
|
large_size dispatch_boost_exception( exception const * );
|
||||||
|
|
||||||
struct small_size { };
|
struct small_size { };
|
||||||
small_size dispatch( void * );
|
small_size dispatch_boost_exception( void const * );
|
||||||
|
|
||||||
template <class,int>
|
template <class,int>
|
||||||
struct enable_error_info_helper;
|
struct enable_error_info_helper;
|
||||||
@ -330,7 +334,7 @@ boost
|
|||||||
struct
|
struct
|
||||||
enable_error_info_return_type
|
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;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,20 +157,35 @@ boost
|
|||||||
return p;
|
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>
|
template <class E,class Tag,class T>
|
||||||
inline
|
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 )
|
operator<<( E const & x, error_info<Tag,T> const & v )
|
||||||
{
|
{
|
||||||
typedef error_info<Tag,T> error_info_tag_t;
|
return exception_detail::set_info(x,v);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,16 +36,32 @@
|
|||||||
#if !defined( BOOST_EXCEPTION_DISABLE )
|
#if !defined( BOOST_EXCEPTION_DISABLE )
|
||||||
# include <boost/exception/exception.hpp>
|
# include <boost/exception/exception.hpp>
|
||||||
# include <boost/current_function.hpp>
|
# include <boost/current_function.hpp>
|
||||||
# define BOOST_THROW_EXCEPTION(x) ::boost::throw_exception(::boost::enable_error_info(x) <<\
|
# define BOOST_THROW_EXCEPTION(x) ::boost::exception_detail::throw_exception_(x,BOOST_CURRENT_FUNCTION,__FILE__,__LINE__)
|
||||||
::boost::throw_function(BOOST_CURRENT_FUNCTION) <<\
|
|
||||||
::boost::throw_file(__FILE__) <<\
|
|
||||||
::boost::throw_line(__LINE__))
|
|
||||||
#else
|
#else
|
||||||
# define BOOST_THROW_EXCEPTION(x) ::boost::throw_exception(x)
|
# define BOOST_THROW_EXCEPTION(x) ::boost::throw_exception(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace boost
|
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
|
#ifdef BOOST_NO_EXCEPTIONS
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
//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/exception/detail/is_output_streamable.hpp>
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
n1
|
n1
|
||||||
@ -31,11 +30,20 @@ n2
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <bool Test>
|
||||||
|
struct test;
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct
|
||||||
|
test<true>
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
BOOST_TEST( !boost::is_output_streamable<n1::c1>::value );
|
test<!boost::is_output_streamable<n1::c1>::value>();
|
||||||
BOOST_TEST( boost::is_output_streamable<n2::c2>::value );
|
test<boost::is_output_streamable<n2::c2>::value>();
|
||||||
BOOST_TEST( boost::is_output_streamable<int>::value );
|
test<boost::is_output_streamable<int>::value>();
|
||||||
return boost::report_errors();
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user