compile_time_assert.hpp
Go to the documentation of this file.
00001 
00010 /*****************************************************************************
00011 ** Ifdefs
00012 *****************************************************************************/
00013 
00014 #ifndef ECL_ERRORS_COMPILE_TIME_ASSERT_HPP_
00015 #define ECL_ERRORS_COMPILE_TIME_ASSERT_HPP_
00016 
00017 /*****************************************************************************
00018 ** Includes
00019 *****************************************************************************/
00020 
00021 #include "macros.hpp"
00022 
00023 /*****************************************************************************
00024 ** Namespaces
00025 *****************************************************************************/
00026 
00027 namespace ecl {
00028 
00029 
00030 /*****************************************************************************
00031 ** Classes
00032 *****************************************************************************/
00037 template <bool> struct COMPILE_TIME_FAILURE;
00038 
00039 template <> struct COMPILE_TIME_FAILURE<true> {};
00040 
00041 template <int x> struct static_assert_test {};
00042 
00043 }; // namespace ecl
00060 #define ecl_compile_time_assert( logical_expression ) \
00061    typedef ecl::static_assert_test<sizeof(ecl::COMPILE_TIME_FAILURE< static_cast<bool>(logical_expression) >)> JOIN(compile_time_check,__LINE__)
00062 
00078 // If the (void)ERROR_##message is absent, we get unused variable warnings.
00079 #define ecl_verbose_compile_time_assert( logical_expression, message ) \
00080         { \
00081                 ecl::COMPILE_TIME_FAILURE<( (logical_expression) != 0)> ERROR_##message; \
00082             (void)ERROR_##message; \
00083         }
00084 
00085 #endif /* ECL_ERRORS_COMPILE_TIME_ASSERT_HPP_ */


ecl_errors
Author(s): Daniel Stonier
autogenerated on Sun Oct 5 2014 23:35:26