MorphoGraphX
StaticAssert.hpp
Go to the documentation of this file.
1 //
2 // This file is part of MorphoGraphX - http://www.MorphoGraphX.org
3 // Copyright (C) 2012-2015 Richard S. Smith and collaborators.
4 //
5 // If you use MorphoGraphX in your work, please cite:
6 // http://dx.doi.org/10.7554/eLife.05864
7 //
8 // MorphoGraphX is free software, and is licensed under under the terms of the
9 // GNU General (GPL) Public License version 2.0, http://www.gnu.org/licenses.
10 //
11 #ifndef STATIC_ASSERT_H
12 #define STATIC_ASSERT_H
13 
19 namespace mgx {
20 namespace util {
21 // Extracted from boost static_asset.h ...
22 template <bool x> struct STATIC_ASSERTION_FAILURE;
23 template <> struct STATIC_ASSERTION_FAILURE<true> {
24  enum { value = 1 };
25 };
26 template <int x> struct static_assert_test {
27 };
28 
29 #define _MGX_JOIN(X, Y) _MGX_DO_JOIN(X, Y)
30 #define _MGX_DO_JOIN(X, Y) _MGX_DO_JOIN2(X, Y)
31 #define _MGX_DO_JOIN2(X, Y) X ## Y
32 
57 #define STATIC_ASSERT(B) \
58  typedef mgx::util::static_assert_test<sizeof(mgx::util::STATIC_ASSERTION_FAILURE<(bool)(B)>)> \
59  _MGX_JOIN (static_assert_typedef_, __LINE__)
60 } // namespace util
61 } // namespace mgx
62 #endif // STATIC_ASSERT_H
Definition: StaticAssert.hpp:26
This namespace contains all the API of MorphoGraphX.
Definition: Assert.hpp:26
Definition: StaticAssert.hpp:22