mirror of
https://github.com/boostorg/variant2.git
synced 2025-07-30 04:07:16 +02:00
Support -fno-exceptions
This commit is contained in:
@ -29,6 +29,13 @@
|
|||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#ifdef BOOST_NO_EXCEPTIONS
|
||||||
|
|
||||||
|
BOOST_NORETURN void throw_exception( std::exception const & e ); // user defined
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace variant2
|
namespace variant2
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -53,7 +60,15 @@ namespace detail
|
|||||||
|
|
||||||
BOOST_NORETURN inline void throw_bad_variant_access()
|
BOOST_NORETURN inline void throw_bad_variant_access()
|
||||||
{
|
{
|
||||||
|
#ifdef BOOST_NO_EXCEPTIONS
|
||||||
|
|
||||||
|
boost::throw_exception( bad_variant_access() );
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
throw bad_variant_access();
|
throw bad_variant_access();
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
14
test/Jamfile
14
test/Jamfile
@ -89,3 +89,17 @@ run variant_convert_construct_throw.cpp ;
|
|||||||
|
|
||||||
run variant_copy_assign_throw.cpp ;
|
run variant_copy_assign_throw.cpp ;
|
||||||
run variant_move_assign_throw.cpp ;
|
run variant_move_assign_throw.cpp ;
|
||||||
|
|
||||||
|
local NX =
|
||||||
|
<exception-handling>off
|
||||||
|
<toolset>msvc:<cxxflags>/wd4530
|
||||||
|
<toolset>msvc:<cxxflags>/wd4577
|
||||||
|
;
|
||||||
|
|
||||||
|
run variant_get_by_index.cpp throw_exception.cpp : : : $(NX) : variant_get_by_index_nx ;
|
||||||
|
compile variant_get_by_index_cx.cpp : $(NX) : variant_get_by_index_cx_nx ;
|
||||||
|
|
||||||
|
run variant_get_by_type.cpp throw_exception.cpp : : : $(NX) : variant_get_by_type_nx ;
|
||||||
|
compile variant_get_by_type_cx.cpp : $(NX) : variant_get_by_type_cx_nx ;
|
||||||
|
|
||||||
|
run variant_subset.cpp throw_exception.cpp : : : $(NX) : variant_subset_nx ;
|
||||||
|
19
test/throw_exception.cpp
Normal file
19
test/throw_exception.cpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
|
||||||
|
// Copyright 2019 Peter Dimov.
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
#include <exception>
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
|
||||||
|
void throw_exception( std::exception const & e )
|
||||||
|
{
|
||||||
|
std::fprintf( stderr, "Exception: %s\n", e.what() );
|
||||||
|
std::terminate();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace boost
|
Reference in New Issue
Block a user