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