//-----------------------------------------------------------------------------
//
// Copyright (c) 2003 Eric Friedman
-// Copyright (c) 2015-2016 Antony Polukhin
+// Copyright (c) 2015-2019 Antony Polukhin
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
#define BOOST_VARIANT_DETAIL_FORCED_RETURN_HPP
#include <boost/config.hpp>
-#include <boost/variant/detail/generic_result_type.hpp>
#include <boost/assert.hpp>
-#include <cstdlib> // std::abort
#ifdef BOOST_MSVC
namespace boost { namespace detail { namespace variant {
-BOOST_NORETURN inline void forced_return_no_return() { // fixes `must return a value` warnings
- using namespace std;
- abort(); // some implementations have no std::abort
-}
-
-
///////////////////////////////////////////////////////////////////////////////
// (detail) function template forced_return
//
// compile-time requirement of returning a result value.
//
template <typename T>
-BOOST_NORETURN inline
- BOOST_VARIANT_AUX_GENERIC_RESULT_TYPE(T)
+BOOST_NORETURN inline 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
+ T (*dummy)() = 0;
+ (void)dummy;
+ BOOST_UNREACHABLE_RETURN(dummy());
}
}}} // namespace boost::detail::variant