Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54279 - in trunk/boost/spirit/home: . karma/binary karma/char karma/numeric karma/stream karma/string lex/lexer/lexertl qi/binary qi/char qi/numeric support
From: hartmut.kaiser_at_[hidden]
Date: 2009-06-23 10:40:24


Author: hkaiser
Date: 2009-06-23 10:40:22 EDT (Tue, 23 Jun 2009)
New Revision: 54279
URL: http://svn.boost.org/trac/boost/changeset/54279

Log:
Spirit: added a workaround for the MPL problem in BOOST_MPL_ASSERT_MSG generating multiple definition linker errors for certain compilers (VC++)
Added:
   trunk/boost/spirit/home/support/assert_msg.hpp (contents, props changed)
Text files modified:
   trunk/boost/spirit/home/karma/binary/binary.hpp | 6 +++---
   trunk/boost/spirit/home/karma/char/char.hpp | 2 +-
   trunk/boost/spirit/home/karma/numeric/int.hpp | 10 +++++-----
   trunk/boost/spirit/home/karma/numeric/real.hpp | 2 +-
   trunk/boost/spirit/home/karma/numeric/uint.hpp | 10 +++++-----
   trunk/boost/spirit/home/karma/stream/stream.hpp | 2 +-
   trunk/boost/spirit/home/karma/string/lit.hpp | 2 +-
   trunk/boost/spirit/home/lex/lexer/lexertl/token.hpp | 4 ++++
   trunk/boost/spirit/home/qi/binary/binary.hpp | 4 ++--
   trunk/boost/spirit/home/qi/char/char.hpp | 4 ++--
   trunk/boost/spirit/home/qi/char/char_parser.hpp | 2 +-
   trunk/boost/spirit/home/qi/numeric/int.hpp | 2 +-
   trunk/boost/spirit/home/qi/numeric/numeric_utils.hpp | 5 +++--
   trunk/boost/spirit/home/qi/numeric/uint.hpp | 2 +-
   trunk/boost/spirit/home/support.hpp | 1 +
   trunk/boost/spirit/home/support/argument.hpp | 3 ++-
   trunk/boost/spirit/home/support/context.hpp | 5 +++--
   trunk/boost/spirit/home/support/meta_compiler.hpp | 8 ++------
   18 files changed, 39 insertions(+), 35 deletions(-)

Modified: trunk/boost/spirit/home/karma/binary/binary.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/binary/binary.hpp (original)
+++ trunk/boost/spirit/home/karma/binary/binary.hpp 2009-06-23 10:40:22 EDT (Tue, 23 Jun 2009)
@@ -97,11 +97,11 @@
         struct integer
         {
 #ifdef BOOST_HAS_LONG_LONG
- BOOST_MPL_ASSERT_MSG(
+ BOOST_SPIRIT_ASSERT_MSG(
                 bits == 8 || bits == 16 || bits == 32 || bits == 64,
                 not_supported_binary_size, ());
 #else
- BOOST_MPL_ASSERT_MSG(
+ BOOST_SPIRIT_ASSERT_MSG(
                 bits == 8 || bits == 16 || bits == 32,
                 not_supported_binary_size, ());
 #endif
@@ -206,7 +206,7 @@
         static bool generate(OutputIterator& sink, Context&, Delimiter const& d
           , unused_type)
         {
- BOOST_MPL_ASSERT_MSG(false,
+ BOOST_SPIRIT_ASSERT_MSG(false,
                 binary_generator_not_usable_without_attribute, ());
             return false;
         }

Modified: trunk/boost/spirit/home/karma/char/char.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/char/char.hpp (original)
+++ trunk/boost/spirit/home/karma/char/char.hpp 2009-06-23 10:40:22 EDT (Tue, 23 Jun 2009)
@@ -121,7 +121,7 @@
             // providing any attribute, as the generator doesn't 'know' what
             // character to output. The following assertion fires if this
             // situation is detected in your code.
- BOOST_MPL_ASSERT_MSG(false, char__not_usable_without_attribute, ());
+ BOOST_SPIRIT_ASSERT_MSG(false, char__not_usable_without_attribute, ());
             return false;
         }
 

Modified: trunk/boost/spirit/home/karma/numeric/int.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/numeric/int.hpp (original)
+++ trunk/boost/spirit/home/karma/numeric/int.hpp 2009-06-23 10:40:22 EDT (Tue, 23 Jun 2009)
@@ -165,11 +165,11 @@
         };
 
         // check template Attribute 'Radix' for validity
- BOOST_MPL_ASSERT_MSG(
+ BOOST_SPIRIT_ASSERT_MSG(
             Radix == 2 || Radix == 8 || Radix == 10 || Radix == 16,
             not_supported_radix, ());
 
- BOOST_MPL_ASSERT_MSG(std::numeric_limits<T>::is_signed,
+ BOOST_SPIRIT_ASSERT_MSG(std::numeric_limits<T>::is_signed,
             signed_unsigned_mismatch, ());
 
         // int has a Attribute attached
@@ -193,7 +193,7 @@
         static bool
         generate(OutputIterator&, Context&, Delimiter const&, unused_type)
         {
- BOOST_MPL_ASSERT_MSG(false, int__not_usable_without_attribute, ());
+ BOOST_SPIRIT_ASSERT_MSG(false, int__not_usable_without_attribute, ());
             return false;
         }
 
@@ -227,11 +227,11 @@
           : n_(n) {}
 
         // check template Attribute 'Radix' for validity
- BOOST_MPL_ASSERT_MSG(
+ BOOST_SPIRIT_ASSERT_MSG(
             Radix == 2 || Radix == 8 || Radix == 10 || Radix == 16,
             not_supported_radix, ());
 
- BOOST_MPL_ASSERT_MSG(std::numeric_limits<T>::is_signed,
+ BOOST_SPIRIT_ASSERT_MSG(std::numeric_limits<T>::is_signed,
             signed_unsigned_mismatch, ());
 
         template <typename OutputIterator, typename Context, typename Delimiter

Modified: trunk/boost/spirit/home/karma/numeric/real.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/numeric/real.hpp (original)
+++ trunk/boost/spirit/home/karma/numeric/real.hpp 2009-06-23 10:40:22 EDT (Tue, 23 Jun 2009)
@@ -169,7 +169,7 @@
         static bool generate(OutputIterator&, Context&, Delimiter const&
           , unused_type)
         {
- BOOST_MPL_ASSERT_MSG(false, real_not_usable_without_attribute, ());
+ BOOST_SPIRIT_ASSERT_MSG(false, real_not_usable_without_attribute, ());
             return false;
         }
 

Modified: trunk/boost/spirit/home/karma/numeric/uint.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/numeric/uint.hpp (original)
+++ trunk/boost/spirit/home/karma/numeric/uint.hpp 2009-06-23 10:40:22 EDT (Tue, 23 Jun 2009)
@@ -206,11 +206,11 @@
         };
 
         // check template Attribute 'Radix' for validity
- BOOST_MPL_ASSERT_MSG(
+ BOOST_SPIRIT_ASSERT_MSG(
             Radix == 2 || Radix == 8 || Radix == 10 || Radix == 16,
             not_supported_radix, ());
 
- BOOST_MPL_ASSERT_MSG(!std::numeric_limits<T>::is_signed,
+ BOOST_SPIRIT_ASSERT_MSG(!std::numeric_limits<T>::is_signed,
             signed_unsigned_mismatch, ());
 
         // int has a Attribute attached
@@ -231,7 +231,7 @@
         static bool
         generate(OutputIterator&, Context&, Delimiter const&, unused_type)
         {
- BOOST_MPL_ASSERT_MSG(false, uint__not_usable_without_attribute, ());
+ BOOST_SPIRIT_ASSERT_MSG(false, uint__not_usable_without_attribute, ());
             return false;
         }
 
@@ -265,11 +265,11 @@
           : n_(n) {}
 
         // check template Attribute 'Radix' for validity
- BOOST_MPL_ASSERT_MSG(
+ BOOST_SPIRIT_ASSERT_MSG(
             Radix == 2 || Radix == 8 || Radix == 10 || Radix == 16,
             not_supported_radix, ());
 
- BOOST_MPL_ASSERT_MSG(!std::numeric_limits<T>::is_signed,
+ BOOST_SPIRIT_ASSERT_MSG(!std::numeric_limits<T>::is_signed,
             signed_unsigned_mismatch, ());
 
         template <typename OutputIterator, typename Context, typename Delimiter

Modified: trunk/boost/spirit/home/karma/stream/stream.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/stream/stream.hpp (original)
+++ trunk/boost/spirit/home/karma/stream/stream.hpp 2009-06-23 10:40:22 EDT (Tue, 23 Jun 2009)
@@ -143,7 +143,7 @@
         static bool
         generate(OutputIterator&, Context&, Delimiter const&, unused_type)
         {
- BOOST_MPL_ASSERT_MSG(false, stream__not_usable_without_attribute,
+ BOOST_SPIRIT_ASSERT_MSG(false, stream__not_usable_without_attribute,
                 (OutputIterator, Delimiter));
             return false;
         }

Modified: trunk/boost/spirit/home/karma/string/lit.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/string/lit.hpp (original)
+++ trunk/boost/spirit/home/karma/string/lit.hpp 2009-06-23 10:40:22 EDT (Tue, 23 Jun 2009)
@@ -105,7 +105,7 @@
             // providing any attribute, as the generator doesn't 'know' what
             // character to output. The following assertion fires if this
             // situation is detected in your code.
- BOOST_MPL_ASSERT_MSG(false, string_not_usable_without_attribute, ());
+ BOOST_SPIRIT_ASSERT_MSG(false, string_not_usable_without_attribute, ());
             return false;
         }
 

Modified: trunk/boost/spirit/home/lex/lexer/lexertl/token.hpp
==============================================================================
--- trunk/boost/spirit/home/lex/lexer/lexertl/token.hpp (original)
+++ trunk/boost/spirit/home/lex/lexer/lexertl/token.hpp 2009-06-23 10:40:22 EDT (Tue, 23 Jun 2009)
@@ -28,6 +28,10 @@
 #include <boost/mpl/identity.hpp>
 #include <boost/mpl/if.hpp>
 #include <boost/range/iterator_range.hpp>
+#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
+#include <boost/static_assert.hpp>
+#endif
+
 #if defined(BOOST_SPIRIT_DEBUG)
 #include <iosfwd>
 #endif

Modified: trunk/boost/spirit/home/qi/binary/binary.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/binary/binary.hpp (original)
+++ trunk/boost/spirit/home/qi/binary/binary.hpp 2009-06-23 10:40:22 EDT (Tue, 23 Jun 2009)
@@ -93,11 +93,11 @@
         struct integer
         {
 #ifdef BOOST_HAS_LONG_LONG
- BOOST_MPL_ASSERT_MSG(
+ BOOST_SPIRIT_ASSERT_MSG(
                 bits == 8 || bits == 16 || bits == 32 || bits == 64,
                 not_supported_binary_size, ());
 #else
- BOOST_MPL_ASSERT_MSG(
+ BOOST_SPIRIT_ASSERT_MSG(
                 bits == 8 || bits == 16 || bits == 32,
                 not_supported_binary_size, ());
 #endif

Modified: trunk/boost/spirit/home/qi/char/char.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/char/char.hpp (original)
+++ trunk/boost/spirit/home/qi/char/char.hpp 2009-06-23 10:40:22 EDT (Tue, 23 Jun 2009)
@@ -250,7 +250,7 @@
         {
             typedef typename traits::char_type_of<String>::type in_type;
 
- BOOST_MPL_ASSERT_MSG((
+ BOOST_SPIRIT_ASSERT_MSG((
                 (sizeof(char_type) == sizeof(in_type))
             ), cannot_convert_string, (String));
 
@@ -306,7 +306,7 @@
         {
             typedef typename traits::char_type_of<String>::type in_type;
 
- BOOST_MPL_ASSERT_MSG((
+ BOOST_SPIRIT_ASSERT_MSG((
                 (sizeof(char_type) == sizeof(in_type))
             ), cannot_convert_string, (String));
 

Modified: trunk/boost/spirit/home/qi/char/char_parser.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/char/char_parser.hpp (original)
+++ trunk/boost/spirit/home/qi/char/char_parser.hpp 2009-06-23 10:40:22 EDT (Tue, 23 Jun 2009)
@@ -138,7 +138,7 @@
             fusion::result_of::value_at_c<Elements, 0>::type
         subject;
 
- BOOST_MPL_ASSERT_MSG((
+ BOOST_SPIRIT_ASSERT_MSG((
             traits::is_char_parser<subject>::value
         ), subject_is_not_negatable, (subject));
 

Modified: trunk/boost/spirit/home/qi/numeric/int.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/numeric/int.hpp (original)
+++ trunk/boost/spirit/home/qi/numeric/int.hpp 2009-06-23 10:40:22 EDT (Tue, 23 Jun 2009)
@@ -68,7 +68,7 @@
       : primitive_parser<int_parser_impl<T, Radix, MinDigits, MaxDigits> >
     {
         // check template parameter 'Radix' for validity
- BOOST_MPL_ASSERT_MSG(
+ BOOST_SPIRIT_ASSERT_MSG(
             Radix == 2 || Radix == 8 || Radix == 10 || Radix == 16,
             not_supported_radix, ());
 

Modified: trunk/boost/spirit/home/qi/numeric/numeric_utils.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/numeric/numeric_utils.hpp (original)
+++ trunk/boost/spirit/home/qi/numeric/numeric_utils.hpp 2009-06-23 10:40:22 EDT (Tue, 23 Jun 2009)
@@ -11,6 +11,7 @@
 #pragma once
 #endif
 
+#include <boost/spirit/home/support/assert_msg.hpp>
 #include <boost/spirit/home/qi/numeric/detail/numeric_utils.hpp>
 #include <boost/assert.hpp>
 #include <boost/mpl/assert.hpp>
@@ -44,7 +45,7 @@
     struct extract_uint
     {
         // check template parameter 'Radix' for validity
- BOOST_MPL_ASSERT_MSG(
+ BOOST_SPIRIT_ASSERT_MSG(
             Radix == 2 || Radix == 8 || Radix == 10 || Radix == 16,
             not_supported_radix, ());
 
@@ -80,7 +81,7 @@
     struct extract_int
     {
         // check template parameter 'Radix' for validity
- BOOST_MPL_ASSERT_MSG(
+ BOOST_SPIRIT_ASSERT_MSG(
             Radix == 2 || Radix == 8 || Radix == 10 || Radix == 16,
             not_supported_radix, ());
 

Modified: trunk/boost/spirit/home/qi/numeric/uint.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/numeric/uint.hpp (original)
+++ trunk/boost/spirit/home/qi/numeric/uint.hpp 2009-06-23 10:40:22 EDT (Tue, 23 Jun 2009)
@@ -86,7 +86,7 @@
       : primitive_parser<uint_parser_impl<T, Radix, MinDigits, MaxDigits> >
     {
         // check template parameter 'Radix' for validity
- BOOST_MPL_ASSERT_MSG(
+ BOOST_SPIRIT_ASSERT_MSG(
             Radix == 2 || Radix == 8 || Radix == 10 || Radix == 16,
             not_supported_radix, ());
 

Modified: trunk/boost/spirit/home/support.hpp
==============================================================================
--- trunk/boost/spirit/home/support.hpp (original)
+++ trunk/boost/spirit/home/support.hpp 2009-06-23 10:40:22 EDT (Tue, 23 Jun 2009)
@@ -11,6 +11,7 @@
 #pragma once
 #endif
 
+#include<boost/spirit/home/support/assert_msg.hpp>
 #include<boost/spirit/home/support/action_dispatch.hpp>
 #include<boost/spirit/home/support/argument.hpp>
 #include<boost/spirit/home/support/attributes.hpp>

Modified: trunk/boost/spirit/home/support/argument.hpp
==============================================================================
--- trunk/boost/spirit/home/support/argument.hpp (original)
+++ trunk/boost/spirit/home/support/argument.hpp 2009-06-23 10:40:22 EDT (Tue, 23 Jun 2009)
@@ -11,6 +11,7 @@
 #include <boost/preprocessor/arithmetic/inc.hpp>
 #include <boost/spirit/home/phoenix/core/actor.hpp>
 #include <boost/spirit/home/phoenix/core/argument.hpp>
+#include <boost/spirit/home/support/assert_msg.hpp>
 #include <boost/fusion/include/at.hpp>
 #include <boost/fusion/include/size.hpp>
 #include <boost/mpl/size.hpp>
@@ -38,7 +39,7 @@
             sequence_size;
 
             // report invalid argument not found (N is out of bounds)
- BOOST_MPL_ASSERT_MSG(
+ BOOST_SPIRIT_ASSERT_MSG(
                 (N < sequence_size::value),
                 index_is_out_of_bounds, ());
 

Added: trunk/boost/spirit/home/support/assert_msg.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/spirit/home/support/assert_msg.hpp 2009-06-23 10:40:22 EDT (Tue, 23 Jun 2009)
@@ -0,0 +1,31 @@
+// Copyright (c) 2001-2009 Hartmut Kaiser
+//
+// 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)
+
+#if !defined(BOOST_SPIRIT_ASSERT_MSG_JUN_23_2009_0836AM)
+#define BOOST_SPIRIT_ASSERT_MSG_JUN_23_2009_0836AM
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+#pragma once // MS compatible compilers support #pragma once
+#endif
+
+// Allow to work around the MPL problem in BOOST_MPL_ASSERT_MSG generating
+// multiple definition linker errors for certain compilers (VC++)
+#if BOOST_SPIRIT_DONT_USE_MPL_ASSERT_MSG != 0
+#include <boost/static_assert.hpp>
+#define BOOST_SPIRIT_ASSERT_MSG(Cond, Msg, Types) \
+ BOOST_STATIC_ASSERT(Cond);
+#else
+#include <boost/mpl/assert.hpp>
+#define BOOST_SPIRIT_ASSERT_MSG(Cond, Msg, Types) \
+ BOOST_MPL_ASSERT_MSG(Cond, Msg, Types);
+#endif
+
+#define BOOST_SPIRIT_ASSERT_MATCH(Domain, Expr) \
+ BOOST_SPIRIT_ASSERT_MSG(( \
+ boost::spirit::traits::matches<Domain, Expr>::value \
+ ), error_invalid_expression, (Expr))
+
+#endif
+

Modified: trunk/boost/spirit/home/support/context.hpp
==============================================================================
--- trunk/boost/spirit/home/support/context.hpp (original)
+++ trunk/boost/spirit/home/support/context.hpp 2009-06-23 10:40:22 EDT (Tue, 23 Jun 2009)
@@ -13,6 +13,7 @@
 
 #include <boost/preprocessor/repetition/repeat_from_to.hpp>
 #include <boost/spirit/home/support/nonterminal/expand_arg.hpp>
+#include <boost/spirit/home/support/assert_msg.hpp>
 #include <boost/spirit/home/phoenix/core/actor.hpp>
 #include <boost/spirit/home/phoenix/core/argument.hpp>
 #include <boost/fusion/include/at.hpp>
@@ -115,7 +116,7 @@
             attributes_size;
 
             // report invalid argument not found (N is out of bounds)
- BOOST_MPL_ASSERT_MSG(
+ BOOST_SPIRIT_ASSERT_MSG(
                 (N < attributes_size::value),
                 index_is_out_of_bounds, ());
 
@@ -151,7 +152,7 @@
             locals_size;
 
             // report invalid argument not found (N is out of bounds)
- BOOST_MPL_ASSERT_MSG(
+ BOOST_SPIRIT_ASSERT_MSG(
                 (N < locals_size::value),
                 index_is_out_of_bounds, ());
 

Modified: trunk/boost/spirit/home/support/meta_compiler.hpp
==============================================================================
--- trunk/boost/spirit/home/support/meta_compiler.hpp (original)
+++ trunk/boost/spirit/home/support/meta_compiler.hpp 2009-06-23 10:40:22 EDT (Tue, 23 Jun 2009)
@@ -17,6 +17,7 @@
 #include <boost/spirit/home/support/modify.hpp>
 #include <boost/spirit/home/support/detail/make_cons.hpp>
 #include <boost/spirit/home/support/unused.hpp>
+#include <boost/spirit/home/support/assert_msg.hpp>
 #include <boost/utility/enable_if.hpp>
 
 namespace boost { namespace spirit
@@ -60,7 +61,7 @@
     {
         struct meta_grammar;
 
- BOOST_MPL_ASSERT_MSG((
+ BOOST_SPIRIT_ASSERT_MSG((
             !use_operator<Domain, proto::tag::subscript>::value
         ), error_proto_tag_subscript_cannot_be_used, ());
 
@@ -253,9 +254,4 @@
 
 }}
 
-#define BOOST_SPIRIT_ASSERT_MATCH(Domain, Expr) \
- BOOST_MPL_ASSERT_MSG(( \
- boost::spirit::traits::matches<Domain, Expr>::value \
- ), error_invalid_expression, (Expr));
-
 #endif


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk