From 3b8145188ca52f1a21cacd7b284e32dbda7c4b09 Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Sat, 16 Mar 2019 17:47:19 -0400 Subject: [PATCH] inplace_function: Use a conditional macro to throw. You can now use "inplace_function.h" with -fno-exceptions. The intended usage is #define SG14_INPLACE_FUNCTION_THROW(x) __builtin_unreachable() #include "inplace_function.h" Thanks to @AndWass for the patch! Fixes #152. Fixes #153. --- SG14/inplace_function.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/SG14/inplace_function.h b/SG14/inplace_function.h index 0db50777..f36d988b 100644 --- a/SG14/inplace_function.h +++ b/SG14/inplace_function.h @@ -30,6 +30,10 @@ #include #include +#ifndef SG14_INPLACE_FUNCTION_THROW +#define SG14_INPLACE_FUNCTION_THROW(x) throw (x) +#endif + namespace stdext { namespace inplace_function_detail { @@ -92,7 +96,7 @@ template struct vtable explicit constexpr vtable() noexcept : invoke_ptr{ [](storage_ptr_t, Args&&...) -> R - { throw std::bad_function_call(); } + { SG14_INPLACE_FUNCTION_THROW(std::bad_function_call()); } }, copy_ptr{ [](storage_ptr_t, storage_ptr_t) -> void {} }, relocate_ptr{ [](storage_ptr_t, storage_ptr_t) -> void {} },