meta.hh

Go to the documentation of this file.
00001 // Copyright (C) 2003, 2004, 2005 Laboratoire de Recherche en Informatique
00002 
00003 // This file is part of Qolyester.
00004 
00005 // Qolyester is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU General Public License
00007 // as published by the Free Software Foundation; either version 2
00008 // of the License, or (at your option) any later version.
00009 
00010 // Qolyester is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00018 
00026 
00027 #ifndef QOLYESTER_UTL_META_HH
00028 # define QOLYESTER_UTL_META_HH 1
00029 
00030 # include <ostream>
00031 
00032 namespace olsr {
00033 
00034   namespace utl {
00035 
00036     class NullType {};
00037 
00038     namespace internal {
00039 
00040     // Metaprogramming utilities go here.
00041 
00042     // Static assertion.  Its goal is to catch assertions about static
00043     // operands at compile time.
00044       template <bool assertion> struct static_assert {};
00045       template <> struct static_assert<true> {
00046         static inline void      icheck() {}
00047         static const int        dcheck = 1;
00048       };
00049 
00050     // Static type equality check.
00051       template <typename T1, typename T2> struct same_type {};
00052       template <typename T> struct same_type<T, T> {
00053         static void             icheck() {}
00054         static const int        dcheck = 1;
00055       };
00056 
00057     } // namespace internal
00058 
00059 // Utility definitions.
00064 # define i_static_assert(Assertion...) utl::internal::static_assert<(Assertion)>::icheck()
00065 
00070 # define d_static_assert(Assertion...) utl::internal::static_assert<(Assertion)>::dcheck
00071 
00076 # define i_same_type(Type1, Type2) utl::internal::same_type<Type1, Type2 >::icheck()
00077 
00082 # define d_same_type(Type1, Type2) utl::internal::same_type<Type1, Type2 >::dcheck
00083 
00084     inline
00085     std::ostream& operator<<(std::ostream&, const NullType&);
00086 
00087   } // namespace utl
00088 
00089   typedef utl::NullType null_t;
00090 
00091 } // namespace olsr
00092 
00093 # include "meta.hxx"
00094 
00095 #endif // ! QOLYESTER_UTL_META_HH

Generated on Mon Sep 10 17:02:12 2007 for Qolyester daemon by  doxygen 1.5.1