Implement the compile time checks for hash functions as a function instead of a templated class. Hopefully it will work on more compilers.

[SVN r28053]
This commit is contained in:
Daniel James
2005-04-07 22:14:02 +00:00
parent 2000b1aed8
commit f102d684cf
4 changed files with 6 additions and 7 deletions

View File

@@ -8,10 +8,9 @@
#include <boost/mpl/assert.hpp>
template <class T>
struct compile_time_tests
void compile_time_tests(T*)
{
BOOST_MPL_ASSERT((boost::is_base_and_derived<
std::unary_function<T, std::size_t>, HASH_NAMESPACE::hash<T> >));
BOOST_STATIC_CONSTANT(bool, success = true);
};

View File

@@ -24,7 +24,7 @@
template <class T>
void numeric_test()
{
BOOST_CHECK(compile_time_tests<T>::success);
compile_time_tests((T*) 0);
HASH_NAMESPACE::hash<T> x1;
HASH_NAMESPACE::hash<T> x2;

View File

@@ -23,8 +23,8 @@
BOOST_AUTO_UNIT_TEST(pointer_tests)
{
BOOST_CHECK(compile_time_tests<int*>::success);
BOOST_CHECK(compile_time_tests<void*>::success);
compile_time_tests((int**) 0);
compile_time_tests((void**) 0);
HASH_NAMESPACE::hash<int*> x1;
HASH_NAMESPACE::hash<int*> x2;

View File

@@ -22,7 +22,7 @@
BOOST_AUTO_UNIT_TEST(string_tests)
{
BOOST_CHECK(compile_time_tests<std::string>::success);
compile_time_tests((std::string*) 0);
HASH_NAMESPACE::hash<std::string> x1;
HASH_NAMESPACE::hash<std::string> x2;
@@ -34,7 +34,7 @@ BOOST_AUTO_UNIT_TEST(string_tests)
#if !defined(BOOST_NO_STD_WSTRING)
BOOST_AUTO_UNIT_TEST(wstring_tests)
{
BOOST_CHECK(compile_time_tests<std::wstring>::success);
compile_time_tests((std::wstring*) 0);
HASH_NAMESPACE::hash<std::wstring> x1;
HASH_NAMESPACE::hash<std::wstring> x2;