Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

base/static_check

Go to the documentation of this file.
00001 /****************************************************************************
00002   Copyright (C)2001 by Andrei Alexandrescu
00003 
00004   This file is a derivative of a file from the Loki Library written by
00005   Andrei Alexandrescu.  It was distributed by him under the terms
00006   listed below (titled Loki Original Distribution Terms).
00007   In accordance with the terms, this distribution contains the copyright
00008   notice here and the copyright notice and permission notice
00009   in supporting documentation.  The terms do *not* require
00010   redistribution under those same terms.  This code is distributed
00011   to you under the terms of the GNU General Public License (GPL) 
00012   below.  The GPL does not require you to maintain the terms of
00013   the Loki Original Distribution Terms, but you are encouraged to do so.
00014 
00015   This program/file is free software; you can redistribute it and/or modify
00016   it under the terms of the GNU General Public License as published by
00017   the Free Software Foundation; either version 2 of the License, or
00018   (at your option) any later version.
00019   
00020   This program is distributed in the hope that it will be useful,
00021   but WITHOUT ANY WARRANTY; without even the implied warranty of
00022   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023   GNU General Public License for more details. (http://www.gnu.org)
00024   
00025   You should have received a copy of the GNU General Public License
00026   along with this program; if not, write to the Free Software
00027   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00028   
00029  ****************************************************************************
00030   Loki Original Distribution Terms:
00031 
00032   The Loki Library
00033   Copyright (c) 2001 by Andrei Alexandrescu
00034   This code accompanies the book:
00035   Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design 
00036       Patterns Applied". Copyright (c) 2001. Addison-Wesley.
00037   Permission to use, copy, modify, distribute and sell this software for any 
00038       purpose is hereby granted without fee, provided that the above copyright 
00039       notice appear in all copies and that both that copyright notice and this 
00040       permission notice appear in supporting documentation.
00041   The author or Addison-Welsey Longman make no representations about the 
00042       suitability of this software for any purpose. It is provided "as is" 
00043       without express or implied warranty.
00044  ****************************************************************************
00045 
00046   $Id: static_check 1029 2004-02-11 20:45:54Z jungd $
00047   $Revision: 1.1 $
00048   $Date: 2004-02-11 15:45:54 -0500 (Wed, 11 Feb 2004) $
00049   $Author: jungd $
00050  
00051 ****************************************************************************/
00052 
00053 // Last update: June 20, 2001
00054 
00055 #ifndef STATIC_CHECK_INC_
00056 #define STATIC_CHECK_INC_
00057 
00058 namespace base
00059 {
00060 ////////////////////////////////////////////////////////////////////////////////
00061 // Helper structure for the STATIC_CHECK macro
00062 ////////////////////////////////////////////////////////////////////////////////
00063 
00064     template<int> struct CompileTimeError;
00065     template<> struct CompileTimeError<true> {};
00066 }
00067 
00068 ////////////////////////////////////////////////////////////////////////////////
00069 // macro STATIC_CHECK
00070 // Invocation: STATIC_CHECK(expr, id)
00071 // where:
00072 // expr is a compile-time integral or pointer expression
00073 // id is a C++ identifier that does not need to be defined
00074 // If expr is zero, id will appear in a compile-time error message.
00075 ////////////////////////////////////////////////////////////////////////////////
00076 
00077 #define STATIC_CHECK(expr, msg) \
00078     { base::CompileTimeError<((expr) != 0)> ERROR_##msg; (void)ERROR_##msg; } 
00079 
00080 
00081 ////////////////////////////////////////////////////////////////////////////////
00082 // Change log:
00083 // March 20, 2001: add extra parens to STATIC_CHECK - it looked like a fun 
00084 //     definition
00085 // June 20, 2001: ported by Nick Thurn to gcc 2.95.3. Kudos, Nick!!!
00086 ////////////////////////////////////////////////////////////////////////////////
00087 
00088 #endif // STATIC_CHECK_INC_

Generated on Thu Jul 29 15:56:15 2004 for OpenSim by doxygen 1.3.6