Compare commits

..

2 Commits

Author SHA1 Message Date
f2b7655016 Change del.p_=0 to del.p_=nullptr (#22)
* Change del.p_=0 to del.p_=nullptr

A simple change (I hope) that cleans up compiler warnings and errors.

* Support older compilers

* Update throw_exception.hpp

* Update throw_exception.hpp
2022-06-09 15:54:12 +03:00
68d092f4d7 Update documentation 2022-02-17 01:23:30 +02:00
4 changed files with 19 additions and 17 deletions

View File

@ -44,3 +44,7 @@ enable `boost::exception_ptr` support.
The source location of the exception thrown by `boost::throw_with_location`
can be retrieved, after `catch(std::exception const & x)`, by using
`boost::get_throw_location(x)`.
`boost::get_throw_location` also works for exceptions thrown by the two argument
overload of `boost::throw_exception`, or by `BOOST_THROW_EXCEPTION`; in this case
it returns the source location stored in the `boost::exception` base class.

View File

@ -59,7 +59,7 @@ logical throw point, instead of always pointing into the helper.
----
#include <boost/throw_exception.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/exception/diagnostic_information.hpp>
#include <boost/core/verbose_terminate_handler.hpp>
#include <stdexcept>
#include <cstddef>
#include <iostream>
@ -93,24 +93,21 @@ void f2( std::size_t i, std::size_t n )
int main()
{
try
{
f1( 0, 3 );
f2( 4, 3 );
}
catch( std::exception const & x )
{
std::cerr << boost::diagnostic_information( x ) << std::endl;
}
std::set_terminate( boost::core::verbose_terminate_handler );
f1( 0, 3 );
f2( 4, 3 );
}
----
Sample output:
```none
example.cpp(31): Throw in function void f2(std::size_t, std::size_t)
Dynamic exception type: boost::wrapexcept<std::out_of_range>
std::exception::what: Index out of range: 4 >= 3
std::terminate called after throwing an exception:
type: boost::wrapexcept<std::out_of_range>
what(): Index out of range: 4 >= 3
location: <source>:31:34 in function 'f2'
```
## Using boost::throw_with_location

View File

@ -130,7 +130,8 @@ template<class E> boost::source_location get_throw_location( E const & e );
```
Requires: :: `E` must be polymorphic.
Effects: :: If `e` is a subobject of the object thrown by
`boost::throw_with_location( x, loc )`, returns `loc`. Otherwise, returns
a default constructed source location.
Effects: ::
* If `e` is a subobject of the object thrown by `boost::throw_with_location( x, loc )`, returns `loc`.
* If `dynamic_cast<boost::exception const*>( e )` returns a nonzero value, returns the source location stored in that `boost::exception` subobject, if any.
* Otherwise, returns a default constructed source location.

View File

@ -116,7 +116,7 @@ public:
boost::exception_detail::copy_boost_exception( p, this );
del.p_ = 0;
del.p_ = BOOST_NULLPTR;
return p;
}