GDCM: gdcmStaticAssert.h Source File

GDCM 3.2.8

gdcmStaticAssert.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: GDCM (Grassroots DICOM). A DICOM library
4
5 Copyright (c) 2006-2011 Mathieu Malaterre
6 All rights reserved.
7 See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
8
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the above copyright notice for more information.
12
13=========================================================================*/
14#ifndef GDCMSTATICASSERT_H
15#define GDCMSTATICASSERT_H
16
17
18// the following was shamelessly borowed from BOOST static assert:
19namespace gdcm
20{
21 template <bool x>
22 struct STATIC_ASSERTION_FAILURE;
23
24 template <>
25 struct STATIC_ASSERTION_FAILURE<true> { enum { value = 1 }; };
26
27 template <int x>
28 struct static_assert_test {};
29}
30
31#define GDCM_JOIN( X, Y ) GDCM_DO_JOIN( X, Y )
32#define GDCM_DO_JOIN( X, Y ) GDCM_DO_JOIN2(X,Y)
33#define GDCM_DO_JOIN2( X, Y ) X##Y
34
36#define GDCM_STATIC_ASSERT( B ) \
37 typedef ::gdcm::static_assert_test<\
38 sizeof(::gdcm::STATIC_ASSERTION_FAILURE< (bool)( B ) >)>\
39 GDCM_JOIN(gdcm_static_assert_typedef_, __LINE__)
40
41
42/* Example of use:
43 *
44 * template <class T>
45 * struct must_not_be_instantiated
46 * {
47 * // this will be triggered if this type is instantiated
48 * GDCM_STATIC_ASSERT(sizeof(T) == 0);
49 * };
50 *
51 */
52#endif // GDCMSTATICASSERT_H
gdcm
Definition gdcmASN1.h:21
gdcm::STATIC_ASSERTION_FAILURE< true >::value
@ value
Definition gdcmStaticAssert.h:25
gdcm::STATIC_ASSERTION_FAILURE
Definition gdcmStaticAssert.h:22
gdcm::static_assert_test
Definition gdcmStaticAssert.h:28