1
////////////////////////////////////////////////////////////////////////////////
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 752 2006-10-17 19:52:18Z syntheticpp $
23
////////////////////////////////////////////////////////////////////////////////
24
// Helper structure for the STATIC_CHECK macro
25
////////////////////////////////////////////////////////////////////////////////
27
template<int> struct CompileTimeError;
28
template<> struct CompileTimeError<true> {};
31
////////////////////////////////////////////////////////////////////////////////
33
// Invocation: STATIC_CHECK(expr, id)
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