throw_exception is user-provided in standalone

This commit is contained in:
Vinnie Falco 2020-09-06 05:54:48 -07:00
parent 0c935f9cc9
commit 0acf98c1e6
3 changed files with 14 additions and 7 deletions

View File

@ -75,7 +75,7 @@ as part of Boost, or in the standalone flavor (without Boost):
* Aliases for standard types use their `std` equivalents
* Obtained when defining the macro `BOOST_JSON_STANDALONE`
* Link to a built static or dynamic standalone library, or use header-only (below)
* Supports -fno-exceptions, define `BOOST_NO_EXCEPTIONS` manually
* Supports -fno-exceptions: define `BOOST_NO_EXCEPTIONS` and `boost::throw_exception` manually
### Header-Only

View File

@ -83,7 +83,7 @@ as part of Boost, or in the standalone flavor (without Boost):
* Aliases for standard types use their `std` equivalents
* Obtained when defining the macro `BOOST_JSON_STANDALONE`
* Link to a built static or dynamic standalone library, or use header-only (below)
* Supports -fno-exceptions, define `BOOST_NO_EXCEPTIONS` manually
* Supports -fno-exceptions: define `BOOST_NO_EXCEPTIONS` and `boost::throw_exception` manually
[heading Header-Only]

View File

@ -22,18 +22,25 @@
BOOST_JSON_NS_BEGIN
#ifdef BOOST_JSON_STANDALONE
#ifdef BOOST_NO_EXCEPTIONS
// When exceptions are disabled
// in standalone, you must provide
// this function.
BOOST_NORETURN
void
throw_exception(std::exception const&);
#else
template<class E>
void
BOOST_NORETURN
throw_exception(E e)
{
#ifndef BOOST_NO_EXCEPTIONS
throw e;
#else
(void)e;
std::terminate();
#endif
}
#endif
#endif
namespace detail {