Files
externals/linux/include/ActivBoost/assert.hpp
T

86 lines
2.8 KiB
C++

//
// ActivBoost/assert.hpp - ACTIV_BOOST_ASSERT(expr)
// ACTIV_BOOST_ASSERT_MSG(expr, msg)
// ACTIV_BOOST_VERIFY(expr)
// ACTIV_BOOST_VERIFY_MSG(expr, msg)
// ACTIV_BOOST_ASSERT_IS_VOID
//
// Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
// Copyright (c) 2007, 2014 Peter Dimov
// Copyright (c) Beman Dawes 2011
// Copyright (c) 2015 Ion Gaztanaga
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
// Note: There are no include guards. This is intentional.
//
// See http://www.boost.org/libs/assert/assert.html for documentation.
//
//
// Stop inspect complaining about use of 'assert':
//
// boostinspect:naassert_macro
//
//
// ACTIV_BOOST_ASSERT, ACTIV_BOOST_ASSERT_MSG, ACTIV_BOOST_ASSERT_IS_VOID
//
#undef ACTIV_BOOST_ASSERT
#undef ACTIV_BOOST_ASSERT_MSG
#undef ACTIV_BOOST_ASSERT_IS_VOID
#if defined(ACTIV_BOOST_DISABLE_ASSERTS) || ( defined(ACTIV_BOOST_ENABLE_ASSERT_DEBUG_HANDLER) && defined(NDEBUG) )
# define ACTIV_BOOST_ASSERT(expr) ((void)0)
# define ACTIV_BOOST_ASSERT_MSG(expr, msg) ((void)0)
# define ACTIV_BOOST_ASSERT_IS_VOID
#elif defined(ACTIV_BOOST_ENABLE_ASSERT_HANDLER) || ( defined(ACTIV_BOOST_ENABLE_ASSERT_DEBUG_HANDLER) && !defined(NDEBUG) )
#include <ActivBoost/config.hpp> // for ACTIV_BOOST_LIKELY
#include <ActivBoost/current_function.hpp>
namespace Boost
{
void assertion_failed(char const * expr, char const * function, char const * file, long line); // user defined
void assertion_failed_msg(char const * expr, char const * msg, char const * function, char const * file, long line); // user defined
} // namespace Boost
#define ACTIV_BOOST_ASSERT(expr) (ACTIV_BOOST_LIKELY(!!(expr))? ((void)0): ::Boost::assertion_failed(#expr, ACTIV_BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
#define ACTIV_BOOST_ASSERT_MSG(expr, msg) (ACTIV_BOOST_LIKELY(!!(expr))? ((void)0): ::Boost::assertion_failed_msg(#expr, msg, ACTIV_BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
#else
# include <assert.h> // .h to support old libraries w/o <cassert> - effect is the same
# define ACTIV_BOOST_ASSERT(expr) assert(expr)
# define ACTIV_BOOST_ASSERT_MSG(expr, msg) assert((expr)&&(msg))
#if defined(NDEBUG)
# define ACTIV_BOOST_ASSERT_IS_VOID
#endif
#endif
//
// ACTIV_BOOST_VERIFY, ACTIV_BOOST_VERIFY_MSG
//
#undef ACTIV_BOOST_VERIFY
#undef ACTIV_BOOST_VERIFY_MSG
#if defined(ACTIV_BOOST_DISABLE_ASSERTS) || ( !defined(ACTIV_BOOST_ENABLE_ASSERT_HANDLER) && defined(NDEBUG) )
# define ACTIV_BOOST_VERIFY(expr) ((void)(expr))
# define ACTIV_BOOST_VERIFY_MSG(expr, msg) ((void)(expr))
#else
# define ACTIV_BOOST_VERIFY(expr) ACTIV_BOOST_ASSERT(expr)
# define ACTIV_BOOST_VERIFY_MSG(expr, msg) ACTIV_BOOST_ASSERT_MSG(expr,msg)
#endif