Fixed wrong prediction for incomplete ranges.
[fic.git] / FerrisLoki / static_check.h
blobc04e3e70263672b19f792fda75ac07c7b1fb98dc
1 ////////////////////////////////////////////////////////////////////////////////
2 // The Loki Library
3 // Copyright (c) 2001 by Andrei Alexandrescu
4 // This code accompanies the book:
5 // Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
6 // Patterns Applied". Copyright (c) 2001. Addison-Wesley.
7 // Permission to use, copy, modify, distribute and sell this software for any
8 // purpose is hereby granted without fee, provided that the above copyright
9 // notice appear in all copies and that both that copyright notice and this
10 // permission notice appear in supporting documentation.
11 // The author or Addison-Wesley Longman make no representations about the
12 // suitability of this software for any purpose. It is provided "as is"
13 // without express or implied warranty.
14 ////////////////////////////////////////////////////////////////////////////////
15 #ifndef LOKI_STATIC_CHECK_INC_
16 #define LOKI_STATIC_CHECK_INC_
18 // $Id: static_check.h,v 1.1 2007/12/10 11:58:52 ben Exp $
21 namespace Loki
23 ////////////////////////////////////////////////////////////////////////////////
24 // Helper structure for the STATIC_CHECK macro
25 ////////////////////////////////////////////////////////////////////////////////
27 template<int> struct CompileTimeError;
28 template<> struct CompileTimeError<true> {};
31 ////////////////////////////////////////////////////////////////////////////////
32 // macro STATIC_CHECK
33 // Invocation: STATIC_CHECK(expr, id)
34 // where:
35 // expr is a compile-time integral or pointer expression
36 // id is a C++ identifier that does not need to be defined
37 // If expr is zero, id will appear in a compile-time error message.
38 ////////////////////////////////////////////////////////////////////////////////
40 #define LOKI_STATIC_CHECK(expr, msg) \
41 { Loki::CompileTimeError<((expr) != 0)> ERROR_##msg; (void)ERROR_##msg; }
44 #endif // end file guardian