zenXML
Straightforward C++ XML Processing
assert_static.h
00001 // **************************************************************************
00002 // * This file is part of the FreeFileSync project. It is distributed under *
00003 // * GNU General Public License: http://www.gnu.org/licenses/gpl.html       *
00004 // * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de)                    *
00005 // **************************************************************************
00006 //
00007 #ifndef ASSERTSTATIC_H_INCLUDED
00008 #define ASSERTSTATIC_H_INCLUDED
00009 
00010 //compile time assert based on Loki (http://loki-lib.sourceforge.net)
00011 
00012 #ifdef NDEBUG
00013 
00014 #define assert_static(x)        //((void)0) -> leads to error when seen in namespace scope!
00015 
00016 #else /* debugging enabled */
00017 namespace StaticCheckImpl
00018 {
00019 template<int>
00020 struct CompileTimeError;
00021 
00022 template<>
00023 struct CompileTimeError<true> {};
00024 }
00025 
00026 #define LOKI_CONCAT( X, Y ) LOKI_CONCAT_SUB( X, Y )
00027 #define LOKI_CONCAT_SUB( X, Y ) X##Y
00028 
00029 #define assert_static(expr)  \
00030     enum { LOKI_CONCAT(loki_enum_dummy_value, __LINE__) = sizeof(StaticCheckImpl::CompileTimeError<static_cast<bool>(expr) >) }
00031 
00032 /*#define assert_static(expr) \
00033 { Loki::CompileTimeError<((expr) != 0)> Static_Assert_Has_Failed; (void)Static_Assert_Has_Failed; } */
00034 
00035 #endif
00036 
00037 #endif //ASSERTSTATIC_H_INCLUDED
 All Classes Namespaces Files Functions Variables