diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2016-10-06 10:41:18 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2016-10-06 10:43:11 +0900 |
commit | f763a99a501650eff2c60288aa6f10ef916d769e (patch) | |
tree | 02af7e13f9a38c888ebf340fe764cbe7dae99da9 /boost/variant/detail/forced_return.hpp | |
parent | 5cde13f21d36c7224b0e13d11c4b49379ae5210d (diff) | |
download | boost-f763a99a501650eff2c60288aa6f10ef916d769e.tar.gz boost-f763a99a501650eff2c60288aa6f10ef916d769e.tar.bz2 boost-f763a99a501650eff2c60288aa6f10ef916d769e.zip |
Imported Upstream version 1.62.0upstream/1.62.0
Change-Id: I9d4c1ddb7b7d8f0069217ecc582700f9fda6dd4c
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'boost/variant/detail/forced_return.hpp')
-rw-r--r-- | boost/variant/detail/forced_return.hpp | 90 |
1 files changed, 26 insertions, 64 deletions
diff --git a/boost/variant/detail/forced_return.hpp b/boost/variant/detail/forced_return.hpp index 522b796fe0..333393a2ac 100644 --- a/boost/variant/detail/forced_return.hpp +++ b/boost/variant/detail/forced_return.hpp @@ -3,8 +3,8 @@ // See http://www.boost.org for updates, documentation, and revision history. //----------------------------------------------------------------------------- // -// Copyright (c) 2003 -// Eric Friedman +// Copyright (c) 2003 Eric Friedman +// Copyright (c) 2015-2016 Antony Polukhin // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at @@ -13,90 +13,52 @@ #ifndef BOOST_VARIANT_DETAIL_FORCED_RETURN_HPP #define BOOST_VARIANT_DETAIL_FORCED_RETURN_HPP -#include "boost/config.hpp" -#include "boost/variant/detail/generic_result_type.hpp" -#include "boost/assert.hpp" +#include <boost/config.hpp> +#include <boost/variant/detail/generic_result_type.hpp> +#include <boost/assert.hpp> +#include <cstdlib> // std::abort -namespace boost { -namespace detail { namespace variant { -/////////////////////////////////////////////////////////////////////////////// -// (detail) function template forced_return -// -// Logical error to permit invocation at runtime, but (artificially) satisfies -// compile-time requirement of returning a result value. -// - -#if !defined(BOOST_MSVC) \ - && !defined(BOOST_NO_VOID_RETURNS) - -// "standard" implementation: - -template <typename T> -inline T forced_return() -{ - // logical error: should never be here! (see above) - BOOST_ASSERT(false); +#ifdef BOOST_MSVC +# pragma warning( push ) +# pragma warning( disable : 4702 ) // unreachable code +#endif - T (*dummy_function_ptr)() = 0; - return dummy_function_ptr(); -} +namespace boost { namespace detail { namespace variant { -template <> -inline void forced_return<void>() -{ - // logical error: should never be here! (see above) - BOOST_ASSERT(false); +BOOST_NORETURN inline void forced_return_no_return() { // fixes `must return a value` warnings + using namespace std; + abort(); // some implementations have no std::abort } -#elif !defined(BOOST_MSVC) -// workaround implementation +/////////////////////////////////////////////////////////////////////////////// +// (detail) function template forced_return // -// TODO: Determine the most efficient way to handle this -- as below? by -// throwing? by recursive call to forced_return itself? etc. +// Logical error to permit invocation at runtime, but (artificially) satisfies +// compile-time requirement of returning a result value. // - template <typename T> -inline +BOOST_NORETURN inline BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(T) forced_return() { // logical error: should never be here! (see above) BOOST_ASSERT(false); + forced_return_no_return(); + +#ifdef BOOST_NO_NORETURN BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(T) (*dummy)() = 0; return dummy(); +#endif } -#else // defined(BOOST_MSVC) +}}} // namespace boost::detail::variant -# pragma warning( push ) -# pragma warning( disable : 4702 ) // unreachable code -// msvc-specific implementation -// -// Leverages __declspec(noreturn) for optimized implementation. -// - -__declspec(noreturn) -inline void forced_return_no_return() {}; - -template <typename T> -inline - BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(T) -forced_return() -{ - // logical error: should never be here! (see above) - BOOST_ASSERT(false); - - forced_return_no_return(); -} +#ifdef BOOST_MSVC # pragma warning( pop ) - -#endif // BOOST_MSVC optimization - -}} // namespace detail::variant -} // namespace boost +#endif #endif // BOOST_VARIANT_DETAIL_FORCED_RETURN_HPP |