M
Markus Petermann
Hello,
I have a small problem I want to demonstrate with a small demo program:
-------------- Snip --------------
#include <string>
namespace
{
template< bool I >
struct StaticAssert
{
};
template<>
struct StaticAssert< true >
{
enum { value = 1 };
};
#define STATIC_ASSERT( V ) StaticAssert< V >::value
template< typename T >
std::string dump( const T& value )
{
STATIC_ASSERT( false );
}
template<>
std::string dump( const std::string& value )
{
return value;
}
}
int main( const int argc,
char* argv[] )
{
const std::string text = "Hello World!";
dump( text );
return 0;
}
-------------- Snip --------------
(The upper part is like the BOOST_STATIC_ASSERT.)
This can be compiled perfectly with the GCC 3.3 compiler, but not with
GCC 4.0 or 4.1. I want to keep this code because it causes a compiler
error when the template function is called and not one of the
specialized ones.
Has anybody an idea?
I have a small problem I want to demonstrate with a small demo program:
-------------- Snip --------------
#include <string>
namespace
{
template< bool I >
struct StaticAssert
{
};
template<>
struct StaticAssert< true >
{
enum { value = 1 };
};
#define STATIC_ASSERT( V ) StaticAssert< V >::value
template< typename T >
std::string dump( const T& value )
{
STATIC_ASSERT( false );
}
template<>
std::string dump( const std::string& value )
{
return value;
}
}
int main( const int argc,
char* argv[] )
{
const std::string text = "Hello World!";
dump( text );
return 0;
}
-------------- Snip --------------
(The upper part is like the BOOST_STATIC_ASSERT.)
This can be compiled perfectly with the GCC 3.3 compiler, but not with
GCC 4.0 or 4.1. I want to keep this code because it causes a compiler
error when the template function is called and not one of the
specialized ones.
Has anybody an idea?