Optimization for error_info<throw_function>, error_info<throw_file>, error_info<throw_line>. Refactored exception_ptr to use shared_ptr.

[SVN r48521]
This commit is contained in:
Emil Dotchevski
2008-09-01 21:06:09 +00:00
parent 9a35c999a2
commit b84fb75a60
16 changed files with 418 additions and 455 deletions

View File

@ -11,6 +11,66 @@
typedef boost::error_info<struct tag_test_int,int> test_data;
struct
exception1:
std::exception
{
};
struct
exception2:
std::exception,
boost::exception
{
};
void
boost_throw_exception_test()
{
try
{
BOOST_THROW_EXCEPTION(exception1());
BOOST_TEST(false);
}
catch(
boost::exception & x )
{
boost::shared_ptr<char const * const> file=boost::get_error_info<boost::throw_function>(x);
boost::shared_ptr<char const * const> function=boost::get_error_info<boost::throw_file>(x);
boost::shared_ptr<int const> line=boost::get_error_info<boost::throw_line>(x);
BOOST_TEST( file && *file );
BOOST_TEST( function && *function );
BOOST_TEST( line && *line==32 );
}
catch(
... )
{
BOOST_TEST(false);
}
try
{
BOOST_THROW_EXCEPTION(exception2() << test_data(42));
BOOST_TEST(false);
}
catch(
boost::exception & x )
{
boost::shared_ptr<char const * const> file=boost::get_error_info<boost::throw_function>(x);
boost::shared_ptr<char const * const> function=boost::get_error_info<boost::throw_file>(x);
boost::shared_ptr<int const> line=boost::get_error_info<boost::throw_line>(x);
boost::shared_ptr<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( data && *data==42 );
}
catch(
... )
{
BOOST_TEST(false);
}
}
void
throw_fwd( void (*thrower)(int) )
{
@ -80,6 +140,7 @@ tester()
int
main()
{
boost_throw_exception_test();
tester<boost::exception_test::derives_boost_exception>();
tester<boost::exception_test::derives_boost_exception_virtually>();
tester<boost::exception_test::derives_std_exception>();