cml_assert.h

Go to the documentation of this file.
00001 /* -*- C++ -*- ------------------------------------------------------------
00002  
00003 Copyright (c) 2007 Jesse Anders and Demian Nave http://cmldev.net/
00004 
00005 The Configurable Math Library (CML) is distributed under the terms of the
00006 Boost Software License, v1.0 (see cml/LICENSE for details).
00007 
00008  *-----------------------------------------------------------------------*/
00016 #ifndef cml_assert_h
00017 #define cml_assert_h
00018 
00019 #include <cml/core/cml_meta.h>
00020 
00021 namespace cml {
00022 
00023 /* Join preprocessor macros into a new preprocessor macro: */
00024 #define CML_JOIN(X,Y) CML_DO_JOIN(X,Y)
00025 #define CML_DO_JOIN(X,Y) CML_DO_JOIN2(X,Y)
00026 #define CML_DO_JOIN2(X,Y) X##Y
00027 
00028 /* Change a macro value into a string: */
00029 #define TO_STRING(X) TO_STRING2(X)
00030 #define TO_STRING2(X) #X
00031 
00033 template<bool T> struct STATIC_ASSERTION_FAILURE;
00034 
00036 template<> struct STATIC_ASSERTION_FAILURE<true> {
00037     typedef true_type result;
00038     enum { value = true };
00039 };
00040 
00053 #define CML_STATIC_REQUIRE(_E_) \
00054     typedef typename STATIC_ASSERTION_FAILURE<(_E_)>::result \
00055         CML_JOIN(__cml_assert_test_typedef_, __LINE__)
00056 
00057 
00066 template<bool T, typename M> struct STATIC_ASSERTION_FAILURE_M {
00067     typename M::bogus result;
00068 };
00069 
00071 template<typename M> struct STATIC_ASSERTION_FAILURE_M<true,M> {
00072     typedef true_type result;
00073     enum { value = true };
00074 };
00075 
00088 #define CML_STATIC_REQUIRE_M(_E_, _M_) \
00089     typedef typename STATIC_ASSERTION_FAILURE_M<(_E_),_M_> \
00090         ::result CML_JOIN(__bogus_assert_type_, __LINE__)
00091 
00092 } // namespace cml
00093 
00094 #endif
00095 
00096 // -------------------------------------------------------------------------
00097 // vim:ft=cpp

Generated on Sat Jul 18 19:35:20 2009 for CML 1.0 by  doxygen 1.5.9