assert.hpp
Go to the documentation of this file.
1 // Copyright (C) 2020-2023 Jonathan Müller and lexy contributors
2 // SPDX-License-Identifier: BSL-1.0
3 
4 #ifndef LEXY_DETAIL_ASSERT_HPP_INCLUDED
5 #define LEXY_DETAIL_ASSERT_HPP_INCLUDED
6 
8 
9 #ifndef LEXY_ENABLE_ASSERT
10 
11 // By default, enable assertions if NDEBUG is not defined.
12 
13 # if NDEBUG
14 # define LEXY_ENABLE_ASSERT 0
15 # else
16 # define LEXY_ENABLE_ASSERT 1
17 # endif
18 
19 #endif
20 
21 #if LEXY_ENABLE_ASSERT
22 
23 // We want assertions: use assert() if that's available, otherwise abort.
24 // We don't use assert() directly as that's not constexpr.
25 
26 # if NDEBUG
27 
28 # include <cstdlib>
29 # define LEXY_PRECONDITION(Expr) ((Expr) ? void(0) : std::abort())
30 # define LEXY_ASSERT(Expr, Msg) ((Expr) ? void(0) : std::abort())
31 
32 # else
33 
34 # include <cassert>
35 
36 # define LEXY_PRECONDITION(Expr) ((Expr) ? void(0) : assert(Expr))
37 # define LEXY_ASSERT(Expr, Msg) ((Expr) ? void(0) : assert((Expr) && (Msg)))
38 
39 # endif
40 
41 #else
42 
43 // We don't want assertions.
44 
45 # define LEXY_PRECONDITION(Expr) static_cast<void>(sizeof(Expr))
46 # define LEXY_ASSERT(Expr, Msg) static_cast<void>(sizeof(Expr))
47 
48 #endif
49 
50 #endif // LEXY_DETAIL_ASSERT_HPP_INCLUDED
51 
config.hpp


behaviortree_cpp_v4
Author(s): Davide Faconti
autogenerated on Fri Jun 28 2024 02:20:07