mirror of
https://github.com/boostorg/parser.git
synced 2026-01-19 04:22:13 +00:00
Honor the use of BOOST_DISABLE_ASSERTS even when Boost.Assert is not available.
This commit is contained in:
@@ -91,6 +91,17 @@ alternatives are used. This applies to the use of `BOOST_ASSERT` versus
|
||||
`assert`, and printing typenames with Boost.TypeIndex versus with
|
||||
`std::typeinfo`.
|
||||
|
||||
[note If you want to disable the use of the C macro `assert`, you define
|
||||
`BOOST_DISABLE_ASSERTS`. This is true whether `BOOST_ASSERT` is available or
|
||||
not. ]
|
||||
|
||||
[important _Parser_ uses inline namespaces around definitions of all functions
|
||||
and types that use the optional Boost features; the name of the inline
|
||||
namespace varies depending on whether the Boost implementation is used. So if
|
||||
Boost.TypeIndex is available to one translation unit, but another TU must use
|
||||
`std::typeinfo`, there are no ODR violations. The exception to this is the
|
||||
use of `BOOST_ASSERT`/`assert`; assert macros are inherently ODR traps. ]
|
||||
|
||||
_Parser_ automatically treats aggregate `struct`s as if they were tuples in
|
||||
many cases. There is some metaprogramming logic that makes this work, and
|
||||
this logic has a hard limit on the size of a `struct` that it can operate on.
|
||||
|
||||
@@ -26,7 +26,9 @@
|
||||
/** Asserts that the given condition is true. If
|
||||
`BOOST_PARSER_NO_RUNTIME_ASSERTIONS` macro is defined by the user,
|
||||
`BOOST_PARSER_ASSERT` expends to a compile-time `static_assert()`.
|
||||
Otherwise, it expands to a run-time `BOOST_ASSERT()`. */
|
||||
Otherwise, it expands to a run-time `BOOST_ASSERT()`. Note that defining
|
||||
`BOOST_DISABLE_ASSERTS` disables the use of C `assert`, even when
|
||||
`BOOST_ASSERT` is unavailble. */
|
||||
# define BOOST_PARSER_ASSERT(condition)
|
||||
|
||||
/** Boost.Parser will automatically use concepts to constrain templates when
|
||||
@@ -56,6 +58,8 @@
|
||||
# define BOOST_PARSER_ASSERT(condition) static_assert(condition)
|
||||
# elif defined(BOOST_PARSER_HAVE_BOOST_ASSERT)
|
||||
# define BOOST_PARSER_ASSERT(condition) BOOST_ASSERT(condition)
|
||||
# elif BOOST_DISABLE_ASSERTS
|
||||
# define BOOST_PARSER_ASSERT(condition) ((void)0)
|
||||
# else
|
||||
# define BOOST_PARSER_ASSERT(condition) assert(condition)
|
||||
# endif
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#include <boost/assert.hpp>
|
||||
#define BOOST_PARSER_DEBUG_ASSERT(condition) BOOST_ASSERT(condition)
|
||||
#define BOOST_PARSER_HAVE_BOOST_ASSERT
|
||||
#elif defined(BOOST_DISABLE_ASSERTS)
|
||||
#define BOOST_PARSER_DEBUG_ASSERT(condition) ((void)0)
|
||||
#else
|
||||
#include <cassert>
|
||||
#define BOOST_PARSER_DEBUG_ASSERT(condition) assert(condition)
|
||||
|
||||
Reference in New Issue
Block a user