// (C) 2001, Fernando Luis Cacciola Carballal. // // This material is provided "as is", with absolutely no warranty expressed // or implied. Any use is at your own risk. // // Permission to use or copy this software for any purpose is hereby granted // without fee, provided the above notices are retained on all copies. // Permission to modify the code and to distribute modified code is granted, // provided the above notices are retained, and a notice that the code was // modified is included with the above copyright notice. // // Revision History // // 27 Nov 2001 Initial version (Fernando Cacciola) // // #ifndef BOOST_STATIC_PRINT_27NOV2001_HPP #define BOOST_STATIC_PRINT_27NOV2001_HPP // // The following macros can be used in template metaprogramming to "print" typenames, // integer and boolean values. // Unlike STATIC_ASSERT(), the output is via a warning, so the code compiles without error. // // Example: // // template // struct Foo // { // STATIC_PRINT_TYPE( FOO_TEMPLATE_PARAMETER, T) // } ; // // template class Foo ; // // When the template is instatiated, a warning will be issued inside a function named: // // STATIC_PRINT_TYPE_NAMED_FOO_TEMPLATE_PARAMETER() // // if you locate the message, you can see which is the template function parameter // (in this case 'string') // #define STATIC_PRINT_TYPE(id,type) \ template \ struct STATIC_PRINT_TYPE_##id \ { \ BOOST_STATIC_CONSTANT (bool, value = ( static_cast(0) \ < static_cast(0) \ ) \ ) ; \ } ; \ static const bool static_printing_type_##id = STATIC_PRINT_TYPE_##id::value #define STATIC_PRINT_INT(id,val) \ template \ struct STATIC_PRINT_INT_##id \ { \ BOOST_STATIC_CONSTANT (bool, value = ( static_cast(0) \ < static_cast(0) \ ) \ ) ; \ } ; \ static const bool static_printing_int_##id = STATIC_PRINT_INT_##id::value #define STATIC_PRINT_BOOL(id,val) \ template \ struct STATIC_PRINT_BOOL_##id \ { \ BOOST_STATIC_CONSTANT (bool, value = ( static_cast(0) \ < static_cast(0) \ ) \ ) ; \ } ; \ static const bool static_printing_bool_##id = STATIC_PRINT_BOOL_##id::value #define STATIC_PRINT_MSG(Msg) \ template \ struct STATIC_PRINT_MSG_#Msg \ { \ BOOST_STATIC_CONSTANT (bool, value = ( static_cast(0) \ < static_cast(0) \ ) \ ) ; \ } ; \ static const bool static_printing_msg_#Msg = STATIC_PRINT_MSG_#Msg <0>::value #endif // ///////////////////////////////////////////////////////////////////////////////////////////////