MRPT  2.0.0
xassert.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
11 #include <stdexcept>
12 
13 /** MRPT_LIKELY(): disable the branch prediction and manually setting the
14  * preference
15  * for the positive case.
16  * See:
17  * https://akrzemi1.wordpress.com/2017/05/18/asserts-in-constexpr-functions */
18 #if defined __GNUC__
19 #define MRPT_LIKELY(EXPR) __builtin_expect(!!(EXPR), 1)
20 #else
21 #define MRPT_LIKELY(EXPR) (!!(EXPR))
22 #endif
23 
24 /** MRPT_X_ASSERT(): build error if condition is known not to work at compile
25  * time, throw an exception at runtime if the condition needs to be evaluated.
26  */
27 #define MRPT_X_ASSERT(CHECK) \
28  (MRPT_LIKELY(CHECK) ? void(0) : [] { throw std::runtime_error(#CHECK); }())



Page generated by Doxygen 1.8.14 for MRPT 2.0.0 Git: b38439d21 Tue Mar 31 19:58:06 2020 +0200 at miƩ abr 1 00:50:30 CEST 2020