00001 //************************************************************ 00002 // 00003 // ******* *** *** * 00004 // * * * * 00005 // * * * ***** 00006 // * * *** * * ** * ** *** 00007 // * * * * * * * **** * * * 00008 // * * * * * * * * * * * 00009 // * *** *** * ** ** ** * * 00010 // * 00011 // see http://sourceforge.net/projects/tcsystem/ for details. 00012 // Copyright (C) 2003 - 2007 Thomas Goessler (the____tiger@hotmail.com) 00013 //************************************************************ 00014 // 00015 // TCSystem is the legal property of its developers. 00016 // Please refer to the COPYRIGHT file distributed with this source distribution. 00017 // 00018 // This program is free software; you can redistribute it and/or modify 00019 // it under the terms of the GNU General Public License as published by 00020 // the Free Software Foundation; either version 2 of the License, or 00021 // (at your option) any later version. 00022 // 00023 // This program is distributed in the hope that it will be useful, 00024 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00025 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00026 // GNU General Public License for more details. 00027 // 00028 // You should have received a copy of the GNU General Public License 00029 // along with this program; if not, write to the Free Software 00030 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00031 //---------------------------------------------------------------------- 00032 // $Id: TCAssert.h 780 2007-11-08 15:14:29Z the_____tiger $ 00033 //---------------------------------------------------------------------- 00034 00035 #ifndef _TC_ASSERT_H_ 00036 #define _TC_ASSERT_H_ 00037 00038 #include "TCTypes.h" 00039 00052 #ifndef NDEBUG 00053 # include <cassert> 00058 # define TC_ASSERT(EX) assert(EX) 00059 00063 # define TC_VERIFY(EX) assert(EX) 00064 #else 00065 # define TC_ASSERT(EX) ((void)0) 00066 # define TC_VERIFY(EX) EX 00067 #endif 00068 00069 namespace TC 00070 { 00071 namespace Impl 00072 { 00074 template <bool val> struct CompileTimeAssertFailure; 00076 template <> 00077 struct CompileTimeAssertFailure<true> {}; 00079 template<int x> struct CompileTimeAssertTest {}; 00080 } 00081 } 00082 00083 #define TC_IMPL_JOIN( X, Y ) TC_IMPL_DO_JOIN( X, Y ) 00084 #define TC_IMPL_DO_JOIN( X, Y ) TC_IMPL_DO_JOIN2(X,Y) 00085 #define TC_IMPL_DO_JOIN2( X, Y ) X##Y 00086 00090 #define TC_CT_ASSERT(VAL) \ 00091 typedef TC::Impl::CompileTimeAssertTest< \ 00092 sizeof(TC::Impl::CompileTimeAssertFailure<(bool)(VAL)>) \ 00093 > TC_IMPL_JOIN(__tc_static_assert_type_, __LINE__) 00094 00099 #endif // _TC_ASSERT_H_