Add boost::throw_exception overload taking a boost::source_location; use it in BOOST_THROW_EXCEPTION

This commit is contained in:
Peter Dimov
2019-11-25 19:17:47 +02:00
parent 43a57d518c
commit dad5cb4ed3
3 changed files with 160 additions and 108 deletions

View File

@ -25,10 +25,26 @@ int main()
}
catch( boost::exception const & x )
{
int const * line = boost::get_error_info<boost::throw_line>( x );
{
char const * const * file = boost::get_error_info<boost::throw_file>( x );
BOOST_TEST( line != 0 );
BOOST_TEST_EQ( *line, 24 );
BOOST_TEST( file != 0 );
BOOST_TEST_CSTR_EQ( *file, __FILE__ );
}
{
int const * line = boost::get_error_info<boost::throw_line>( x );
BOOST_TEST( line != 0 );
BOOST_TEST_EQ( *line, 24 );
}
{
char const * const * function = boost::get_error_info<boost::throw_function>( x );
BOOST_TEST( function != 0 );
BOOST_TEST_CSTR_EQ( *function, BOOST_CURRENT_FUNCTION );
}
}
try
@ -37,10 +53,26 @@ int main()
}
catch( boost::exception const & x )
{
int const * line = boost::get_error_info<boost::throw_line>( x );
{
char const * const * file = boost::get_error_info<boost::throw_file>( x );
BOOST_TEST( line != 0 );
BOOST_TEST_EQ( *line, 36 );
BOOST_TEST( file != 0 );
BOOST_TEST_CSTR_EQ( *file, __FILE__ );
}
{
int const * line = boost::get_error_info<boost::throw_line>( x );
BOOST_TEST( line != 0 );
BOOST_TEST_EQ( *line, 52 );
}
{
char const * const * function = boost::get_error_info<boost::throw_function>( x );
BOOST_TEST( function != 0 );
BOOST_TEST_CSTR_EQ( *function, BOOST_CURRENT_FUNCTION );
}
}
return boost::report_errors();