Fix up support for ASIO_NO_EXCEPTIONS.
diff --git a/asio/include/asio/executor.hpp b/asio/include/asio/executor.hpp index 66886da..1810d93 100644 --- a/asio/include/asio/executor.hpp +++ b/asio/include/asio/executor.hpp
@@ -19,6 +19,7 @@ #include <typeinfo> #include "asio/detail/cstddef.hpp" #include "asio/detail/memory.hpp" +#include "asio/detail/throw_exception.hpp" #include "asio/execution_context.hpp" #include "asio/is_executor.hpp" @@ -302,7 +303,12 @@ // Helper function to check and return the implementation pointer. impl_base* get_impl() { - return impl_ ? impl_ : throw bad_executor(); + if (!impl_) + { + bad_executor ex; + asio::detail::throw_exception(ex); + } + return impl_; } // Helper function to clone another implementation.
diff --git a/asio/include/asio/ip/address.hpp b/asio/include/asio/ip/address.hpp index ad20c45..d8068ba 100644 --- a/asio/include/asio/ip/address.hpp +++ b/asio/include/asio/ip/address.hpp
@@ -17,6 +17,7 @@ #include "asio/detail/config.hpp" #include <string> +#include "asio/detail/throw_exception.hpp" #include "asio/detail/type_traits.hpp" #include "asio/error_code.hpp" #include "asio/ip/address_v4.hpp" @@ -242,7 +243,10 @@ typename enable_if<is_same<T, address_v4>::value>::type* = 0) { if (!addr.is_v4()) - throw bad_address_cast(); + { + bad_address_cast ex; + asio::detail::throw_exception(ex); + } return get_v4_helper(addr); } @@ -255,7 +259,10 @@ typename enable_if<is_same<T, address_v6>::value>::type* = 0) { if (!addr.is_v6()) - throw bad_address_cast(); + { + bad_address_cast ex; + asio::detail::throw_exception(ex); + } return get_v6_helper(addr); }
diff --git a/asio/src/tests/unit/unit_test.hpp b/asio/src/tests/unit/unit_test.hpp index 1687c7c..9925bc0 100644 --- a/asio/src/tests/unit/unit_test.hpp +++ b/asio/src/tests/unit/unit_test.hpp
@@ -70,6 +70,23 @@ compile_test<&test>(); \ std::cout << #test << " passed" << std::endl; +#if defined(ASIO_NO_EXCEPTIONS) + +namespace asio { +namespace detail { + +template <typename T> +void throw_exception(const T& t) +{ + std::cout << "Exception: " << t.what() << std::endl; + std::abort(); +} + +} // namespace detail +} // namespace asio + +#endif // defined(ASIO_NO_EXCEPTIONS) + #else // defined(ASIO_STANDALONE) #include <boost/test/unit_test.hpp>