GDCM  2.2.0
gdcmStaticAssert.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program: GDCM (Grassroots DICOM). A DICOM library
00004 
00005   Copyright (c) 2006-2011 Mathieu Malaterre
00006   All rights reserved.
00007   See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
00008 
00009      This software is distributed WITHOUT ANY WARRANTY; without even
00010      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00011      PURPOSE.  See the above copyright notice for more information.
00012 
00013 =========================================================================*/
00014 #ifndef GDCMSTATICASSERT_H
00015 #define GDCMSTATICASSERT_H
00016 
00017 
00018 // the following was shamelessly borowed from BOOST static assert:
00019 namespace gdcm
00020 {
00021   template <bool x>
00022   struct STATIC_ASSERTION_FAILURE;
00023 
00024   template <>
00025   struct STATIC_ASSERTION_FAILURE<true> { enum { value = 1 }; };
00026 
00027   template <int x>
00028   struct static_assert_test {};
00029 }
00030 
00031 #define GDCM_JOIN( X, Y ) GDCM_DO_JOIN( X, Y )
00032 #define GDCM_DO_JOIN( X, Y ) GDCM_DO_JOIN2(X,Y)
00033 #define GDCM_DO_JOIN2( X, Y ) X##Y
00034 
00036 #define GDCM_STATIC_ASSERT( B ) \
00037   typedef ::gdcm::static_assert_test<\
00038     sizeof(::gdcm::STATIC_ASSERTION_FAILURE< (bool)( B ) >)>\
00039       GDCM_JOIN(gdcm_static_assert_typedef_, __LINE__)
00040 
00041 
00042 /* Example of use:
00043  *
00044  * template <class T>
00045  * struct must_not_be_instantiated
00046  * {
00047  * // this will be triggered if this type is instantiated
00048  * GDCM_STATIC_ASSERT(sizeof(T) == 0);
00049  * };
00050  *
00051  */
00052 #endif // GDCMSTATICASSERT_H

Generated on Fri Mar 30 2012 12:44:06 for GDCM by doxygen 1.8.0
SourceForge.net Logo