Project revived from Feb2017
[EroSomnia.git] / deps / boost_1_63_0 / boost / spirit / home / classic / core / assert.hpp
blob47b1b39909da5ecd7309343a6da68476088f76ab
1 /*=============================================================================
2 Copyright (c) 2001-2003 Joel de Guzman
3 Copyright (c) 2002-2003 Hartmut Kaiser
4 http://spirit.sourceforge.net/
6 Distributed under the Boost Software License, Version 1.0. (See accompanying
7 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 =============================================================================*/
9 #if !defined(BOOST_SPIRIT_ASSERT_HPP)
10 #define BOOST_SPIRIT_ASSERT_HPP
12 #include <boost/config.hpp>
13 #include <boost/throw_exception.hpp>
15 ///////////////////////////////////////////////////////////////////////////////
17 // BOOST_SPIRIT_ASSERT is used throughout the framework. It can be
18 // overridden by the user. If BOOST_SPIRIT_ASSERT_EXCEPTION is defined,
19 // then that will be thrown, otherwise, BOOST_SPIRIT_ASSERT simply turns
20 // into a plain BOOST_ASSERT()
22 ///////////////////////////////////////////////////////////////////////////////
23 #if !defined(BOOST_SPIRIT_ASSERT)
24 #if defined(NDEBUG)
25 #define BOOST_SPIRIT_ASSERT(x)
26 #elif defined (BOOST_SPIRIT_ASSERT_EXCEPTION)
27 #define BOOST_SPIRIT_ASSERT_AUX(f, l, x) BOOST_SPIRIT_ASSERT_AUX2(f, l, x)
28 #define BOOST_SPIRIT_ASSERT_AUX2(f, l, x) \
29 do{ if (!(x)) boost::throw_exception( \
30 BOOST_SPIRIT_ASSERT_EXCEPTION(f "(" #l "): " #x)); } while(0)
31 #define BOOST_SPIRIT_ASSERT(x) BOOST_SPIRIT_ASSERT_AUX(__FILE__, __LINE__, x)
32 #else
33 #include <boost/assert.hpp>
34 #define BOOST_SPIRIT_ASSERT(x) BOOST_ASSERT(x)
35 #endif
36 #endif // !defined(BOOST_SPIRIT_ASSERT)
38 #endif // BOOST_SPIRIT_ASSERT_HPP