Chris@16
|
1 // Copyright (c) 2001-2013 Hartmut Kaiser
|
Chris@16
|
2 //
|
Chris@16
|
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
5
|
Chris@16
|
6 #if !defined(BOOST_SPIRIT_ASSERT_MSG_JUN_23_2009_0836AM)
|
Chris@16
|
7 #define BOOST_SPIRIT_ASSERT_MSG_JUN_23_2009_0836AM
|
Chris@16
|
8
|
Chris@16
|
9 #if defined(_MSC_VER)
|
Chris@16
|
10 #pragma once
|
Chris@16
|
11 #endif
|
Chris@16
|
12
|
Chris@16
|
13 #include <boost/config.hpp>
|
Chris@16
|
14
|
Chris@16
|
15 // Work around the MPL problem in BOOST_MPL_ASSERT_MSG generating
|
Chris@16
|
16 // multiple definition linker errors for certain compilers (VC++ 8).
|
Chris@16
|
17 // BOOST_SPIRIT_DONT_USE_MPL_ASSERT_MSG can also be defined by user.
|
Chris@16
|
18 #if !defined(BOOST_SPIRIT_DONT_USE_MPL_ASSERT_MSG)
|
Chris@16
|
19 # if defined(BOOST_MSVC) && BOOST_MSVC < 1500
|
Chris@16
|
20 # define BOOST_SPIRIT_DONT_USE_MPL_ASSERT_MSG 1
|
Chris@16
|
21 # endif
|
Chris@16
|
22 #endif
|
Chris@16
|
23
|
Chris@16
|
24 #if !defined(BOOST_NO_CXX11_STATIC_ASSERT) || BOOST_SPIRIT_DONT_USE_MPL_ASSERT_MSG != 0
|
Chris@16
|
25 #include <boost/static_assert.hpp>
|
Chris@16
|
26 #define BOOST_SPIRIT_ASSERT_MSG(Cond, Msg, Types) \
|
Chris@16
|
27 BOOST_STATIC_ASSERT_MSG(Cond, # Msg)
|
Chris@16
|
28 #else
|
Chris@16
|
29 #include <boost/mpl/assert.hpp>
|
Chris@16
|
30 #define BOOST_SPIRIT_ASSERT_MSG(Cond, Msg, Types) \
|
Chris@16
|
31 BOOST_MPL_ASSERT_MSG(Cond, Msg, Types)
|
Chris@16
|
32 #endif
|
Chris@16
|
33
|
Chris@16
|
34 #define BOOST_SPIRIT_ASSERT_MATCH(Domain, Expr) \
|
Chris@16
|
35 BOOST_SPIRIT_ASSERT_MSG(( \
|
Chris@16
|
36 boost::spirit::traits::matches< Domain, Expr >::value \
|
Chris@16
|
37 ), error_invalid_expression, (Expr))
|
Chris@16
|
38
|
Chris@16
|
39 // GCC 4.7 will overeagerly instantiate static_asserts in template functions,
|
Chris@16
|
40 // if the assert condition does not depend on template parameters
|
Chris@16
|
41 // (see https://svn.boost.org/trac/boost/ticket/8381).
|
Chris@16
|
42 // There are places where we want to use constant false as the condition in
|
Chris@16
|
43 // template functions to indicate that these function overloads should never
|
Chris@16
|
44 // be called. This allows to generate better error messages. To solve this
|
Chris@16
|
45 // problem we make the condition dependent on the template argument and use
|
Chris@16
|
46 // the following macro in such places.
|
Chris@16
|
47 #include <boost/type_traits/is_same.hpp>
|
Chris@16
|
48
|
Chris@16
|
49 #define BOOST_SPIRIT_ASSERT_FAIL(TemplateParam, Msg, Types) \
|
Chris@16
|
50 BOOST_SPIRIT_ASSERT_MSG((!boost::is_same< \
|
Chris@16
|
51 TemplateParam, TemplateParam >::value), Msg, Types)
|
Chris@16
|
52
|
Chris@16
|
53 #endif
|
Chris@16
|
54
|