source: tags/svn.1.5.4/TEMPLATES/static_assert.h

Last change on this file was 7929, checked in by westram, 14 years ago

merge from dev [7844] [7855] [7865] [7869] [7910] [7911]

  • misc minor patches affecting:
    • diff2grep
    • remake_after_change
    • COMPILE_ASSERT
    • warning fixes
  • dont export error from move_group_info
File size: 1.3 KB
Line 
1// ============================================================= //
2//                                                               //
3//   File      : static_assert.h                                 //
4//   Purpose   : compile time assertion                          //
5//                                                               //
6//   Institute of Microbiology (Technical University Munich)     //
7//   http://www.arb-home.de/                                     //
8//                                                               //
9// ============================================================= //
10
11#ifndef STATIC_ASSERT_H
12#define STATIC_ASSERT_H
13
14namespace arb_compile_assertion {
15    template <bool> struct is;
16    template <> struct is<true> { enum { value = 1 }; };
17    template<int x> struct static_assert_test{};
18}
19
20#define CA_JOIN(X,Y) X##Y
21#define CA_JOINTYPE(X,Y) CA_JOIN(X, Y)
22#define CA_UNIQUETYPE(typename) CA_JOINTYPE(typename,__LINE__)
23
24#define COMPILE_ASSERTED_TYPE(const_expression) ::arb_compile_assertion::static_assert_test<sizeof(::arb_compile_assertion::is< (bool)( const_expression ) >)>
25#define COMPILE_ASSERT(const_expression)        typedef COMPILE_ASSERTED_TYPE(const_expression) CA_UNIQUETYPE(_arb_compile_assertion_typedef_)
26
27#else
28#error static_assert.h included twice
29#endif // STATIC_ASSERT_H
Note: See TracBrowser for help on using the repository browser.