ROOT
6.10/00
Reference Guide
ROOT Home Page
Main Page
Tutorials
User's Classes
Namespaces
All Classes
Files
Release Notes
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
math
smatrix
inc
Math
StaticCheck.h
Go to the documentation of this file.
1
// @(#)root/smatrix:$Id$
2
// Authors: T. Glebe, L. Moneta 2005
3
4
5
////////////////////////////////////////////////////////////////////////////////
6
// The Loki Library
7
// Copyright (c) 2001 by Andrei Alexandrescu
8
// This code accompanies the book:
9
// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
10
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
11
// Permission to use, copy, modify, distribute and sell this software for any
12
// purpose is hereby granted without fee, provided that the above copyright
13
// notice appear in all copies and that both that copyright notice and this
14
// permission notice appear in supporting documentation.
15
// The author or Addison-Wesley Longman make no representations about the
16
// suitability of this software for any purpose. It is provided "as is"
17
// without express or implied warranty.
18
////////////////////////////////////////////////////////////////////////////////
19
20
// Last update: June 20, 2001
21
22
#ifndef Root_Math_StaticCheck
23
#define Root_Math_StaticCheck
24
25
26
// case of dictionary generator
27
#if defined(__MAKECINT__) || defined(G__DICTIONARY)
28
29
#include "
Math/MConfig.h
"
30
#include <iostream>
31
#include <cassert>
32
33
#define STATIC_CHECK(expr, msg) \
34
if (!(expr) ) std::cerr << "ERROR: " << #msg << std::endl; \
35
assert(expr);
36
37
#else
38
39
namespace
ROOT
40
{
41
42
namespace
Math {
43
44
#ifndef USE_OLD_SC
45
46
47
template
<
bool
>
struct
CompileTimeChecker
48
{
49
CompileTimeChecker
(
void
*) {}
50
};
51
template
<>
struct
CompileTimeChecker
<false> {};
52
53
}
// end namespace Math
54
}
// end namespace ROOT
55
56
#define STATIC_CHECK(expr, msg) \
57
{ class ERROR_##msg {}; \
58
ERROR_##msg e; \
59
(void) (ROOT::Math::CompileTimeChecker<(expr) != 0> (&e)); }
60
61
62
#else
63
////////////////////////////////////////////////////////////////////////////////
64
// Helper structure for the STATIC_CHECK macro
65
////////////////////////////////////////////////////////////////////////////////
66
67
template
<
int
>
struct
CompileTimeError;
68
template
<>
struct
CompileTimeError<true> {};
69
70
}
// end namespace Math
71
}
// end namespace ROOT
72
73
////////////////////////////////////////////////////////////////////////////////
74
// macro STATIC_CHECK
75
// Invocation: STATIC_CHECK(expr, id)
76
// where:
77
// expr is a compile-time integral or pointer expression
78
// id is a C++ identifier that does not need to be defined
79
// If expr is zero, id will appear in a compile-time error message.
80
////////////////////////////////////////////////////////////////////////////////
81
82
#define STATIC_CHECK(expr, msg) \
83
{ ROOT::Math::CompileTimeError<((expr) != 0)> ERROR_##msg; (void)ERROR_##msg; }
84
85
86
////////////////////////////////////////////////////////////////////////////////
87
// Change log:
88
// March 20, 2001: add extra parens to STATIC_CHECK - it looked like a fun
89
// definition
90
// June 20, 2001: ported by Nick Thurn to gcc 2.95.3. Kudos, Nick!!!
91
////////////////////////////////////////////////////////////////////////////////
92
93
#endif
94
95
#endif
96
97
#endif // STATIC_CHECK_INC_
ROOT::Math::CompileTimeChecker::CompileTimeChecker
CompileTimeChecker(void *)
Definition:
StaticCheck.h:49
ROOT::Math::CompileTimeChecker
Definition:
StaticCheck.h:47
MConfig.h