strusBase  0.17
static_assert.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Patrick P. Frey
3  *
4  * This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7  */
9 #ifndef _STRUS_STATIC_ASSERT_HPP_INCLUDED
10 #define _STRUS_STATIC_ASSERT_HPP_INCLUDED
11 
13 #if defined __GNUC__
14 #define STRUS_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
15 #endif
16 
17 #undef STRUS_USE_STD_STATIC_ASSERT
18 #if __cplusplus >= 201103L
19 #if defined __clang__
20 #define STRUS_USE_STD_STATIC_ASSERT
21 #elif defined __GNUC__
22 #if STRUS_GCC_VERSION >= 40900
23 #define STRUS_USE_STD_STATIC_ASSERT
24 #endif // STRUS_GCC_VERSION
25 #endif // __clang__
26 #endif // __cplusplus
27 
28 #ifdef STRUS_USE_STD_STATIC_ASSERT
29 #include <type_traits>
30 #define STRUS_STATIC_ASSERT( cond ) static_assert( (cond), "static assertion failed")
31 #else //STRUS_USE_STD_STATIC_ASSERT
32 #include <boost/static_assert.hpp>
33 #define STRUS_STATIC_ASSERT( cond ) BOOST_STATIC_ASSERT((cond))
34 #endif //STRUS_USE_STD_STATIC_ASSERT
35 
36 #endif
37