|
||||
File indexing completed on 2025-01-18 10:10:21
0001 // @(#)root/smatrix:$Id$ 0002 // Authors: T. Glebe, L. Moneta 2005 0003 0004 0005 //////////////////////////////////////////////////////////////////////////////// 0006 // The Loki Library 0007 // Copyright (c) 2001 by Andrei Alexandrescu 0008 // This code accompanies the book: 0009 // Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design 0010 // Patterns Applied". Copyright (c) 2001. Addison-Wesley. 0011 // Permission to use, copy, modify, distribute and sell this software for any 0012 // purpose is hereby granted without fee, provided that the above copyright 0013 // notice appear in all copies and that both that copyright notice and this 0014 // permission notice appear in supporting documentation. 0015 // The author or Addison-Wesley Longman make no representations about the 0016 // suitability of this software for any purpose. It is provided "as is" 0017 // without express or implied warranty. 0018 //////////////////////////////////////////////////////////////////////////////// 0019 0020 // Last update: June 20, 2001 0021 0022 #ifndef Root_Math_StaticCheck 0023 #define Root_Math_StaticCheck 0024 0025 0026 // case of dictionary generator 0027 #if defined(__MAKECINT__) || defined(G__DICTIONARY) 0028 0029 #include "Math/MConfig.h" 0030 #include <iostream> 0031 #include <cassert> 0032 0033 #define STATIC_CHECK(expr, msg) \ 0034 if (!(expr) ) std::cerr << "ERROR: " << #msg << std::endl; \ 0035 assert(expr); 0036 0037 #else 0038 0039 namespace ROOT 0040 { 0041 0042 namespace Math { 0043 0044 #ifndef USE_OLD_SC 0045 0046 0047 template<bool> struct CompileTimeChecker 0048 { 0049 CompileTimeChecker(void *) {} 0050 }; 0051 template<> struct CompileTimeChecker<false> {}; 0052 0053 } // end namespace Math 0054 } // end namespace ROOT 0055 0056 #define STATIC_CHECK(expr, msg) \ 0057 { class ERROR_##msg {}; \ 0058 ERROR_##msg e; \ 0059 (void) (ROOT::Math::CompileTimeChecker<(expr) != 0> (&e)); } 0060 0061 0062 #else 0063 //////////////////////////////////////////////////////////////////////////////// 0064 // Helper structure for the STATIC_CHECK macro 0065 //////////////////////////////////////////////////////////////////////////////// 0066 0067 template<int> struct CompileTimeError; 0068 template<> struct CompileTimeError<true> {}; 0069 0070 } // end namespace Math 0071 } // end namespace ROOT 0072 0073 //////////////////////////////////////////////////////////////////////////////// 0074 // macro STATIC_CHECK 0075 // Invocation: STATIC_CHECK(expr, id) 0076 // where: 0077 // expr is a compile-time integral or pointer expression 0078 // id is a C++ identifier that does not need to be defined 0079 // If expr is zero, id will appear in a compile-time error message. 0080 //////////////////////////////////////////////////////////////////////////////// 0081 0082 #define STATIC_CHECK(expr, msg) \ 0083 { ROOT::Math::CompileTimeError<((expr) != 0)> ERROR_##msg; (void)ERROR_##msg; } 0084 0085 0086 //////////////////////////////////////////////////////////////////////////////// 0087 // Change log: 0088 // March 20, 2001: add extra parens to STATIC_CHECK - it looked like a fun 0089 // definition 0090 // June 20, 2001: ported by Nick Thurn to gcc 2.95.3. Kudos, Nick!!! 0091 //////////////////////////////////////////////////////////////////////////////// 0092 0093 #endif 0094 0095 #endif 0096 0097 #endif // STATIC_CHECK_INC_
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |