Chris@16: // Copyright (c) 2001-2013 Hartmut Kaiser Chris@16: // Chris@16: // Distributed under the Boost Software License, Version 1.0. (See accompanying Chris@16: // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: #if !defined(BOOST_SPIRIT_ASSERT_MSG_JUN_23_2009_0836AM) Chris@16: #define BOOST_SPIRIT_ASSERT_MSG_JUN_23_2009_0836AM Chris@16: Chris@16: #if defined(_MSC_VER) Chris@16: #pragma once Chris@16: #endif Chris@16: Chris@16: #include Chris@16: Chris@16: // Work around the MPL problem in BOOST_MPL_ASSERT_MSG generating Chris@16: // multiple definition linker errors for certain compilers (VC++ 8). Chris@16: // BOOST_SPIRIT_DONT_USE_MPL_ASSERT_MSG can also be defined by user. Chris@16: #if !defined(BOOST_SPIRIT_DONT_USE_MPL_ASSERT_MSG) Chris@16: # if defined(BOOST_MSVC) && BOOST_MSVC < 1500 Chris@16: # define BOOST_SPIRIT_DONT_USE_MPL_ASSERT_MSG 1 Chris@16: # endif Chris@16: #endif Chris@16: Chris@16: #if !defined(BOOST_NO_CXX11_STATIC_ASSERT) || BOOST_SPIRIT_DONT_USE_MPL_ASSERT_MSG != 0 Chris@16: #include Chris@16: #define BOOST_SPIRIT_ASSERT_MSG(Cond, Msg, Types) \ Chris@16: BOOST_STATIC_ASSERT_MSG(Cond, # Msg) Chris@16: #else Chris@16: #include Chris@16: #define BOOST_SPIRIT_ASSERT_MSG(Cond, Msg, Types) \ Chris@16: BOOST_MPL_ASSERT_MSG(Cond, Msg, Types) Chris@16: #endif Chris@16: Chris@16: #define BOOST_SPIRIT_ASSERT_MATCH(Domain, Expr) \ Chris@16: BOOST_SPIRIT_ASSERT_MSG(( \ Chris@16: boost::spirit::traits::matches< Domain, Expr >::value \ Chris@16: ), error_invalid_expression, (Expr)) Chris@16: Chris@16: // GCC 4.7 will overeagerly instantiate static_asserts in template functions, Chris@16: // if the assert condition does not depend on template parameters Chris@16: // (see https://svn.boost.org/trac/boost/ticket/8381). Chris@16: // There are places where we want to use constant false as the condition in Chris@16: // template functions to indicate that these function overloads should never Chris@16: // be called. This allows to generate better error messages. To solve this Chris@16: // problem we make the condition dependent on the template argument and use Chris@16: // the following macro in such places. Chris@16: #include Chris@16: Chris@16: #define BOOST_SPIRIT_ASSERT_FAIL(TemplateParam, Msg, Types) \ Chris@16: BOOST_SPIRIT_ASSERT_MSG((!boost::is_same< \ Chris@16: TemplateParam, TemplateParam >::value), Msg, Types) Chris@16: Chris@16: #endif Chris@16: