mirror of
https://github.com/boostorg/functional.git
synced 2025-08-02 14:04:27 +02:00
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:
@@ -8,10 +8,9 @@
|
|||||||
#include <boost/mpl/assert.hpp>
|
#include <boost/mpl/assert.hpp>
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
struct compile_time_tests
|
void compile_time_tests(T*)
|
||||||
{
|
{
|
||||||
BOOST_MPL_ASSERT((boost::is_base_and_derived<
|
BOOST_MPL_ASSERT((boost::is_base_and_derived<
|
||||||
std::unary_function<T, std::size_t>, HASH_NAMESPACE::hash<T> >));
|
std::unary_function<T, std::size_t>, HASH_NAMESPACE::hash<T> >));
|
||||||
BOOST_STATIC_CONSTANT(bool, success = true);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -24,7 +24,7 @@
|
|||||||
template <class T>
|
template <class T>
|
||||||
void numeric_test()
|
void numeric_test()
|
||||||
{
|
{
|
||||||
BOOST_CHECK(compile_time_tests<T>::success);
|
compile_time_tests((T*) 0);
|
||||||
|
|
||||||
HASH_NAMESPACE::hash<T> x1;
|
HASH_NAMESPACE::hash<T> x1;
|
||||||
HASH_NAMESPACE::hash<T> x2;
|
HASH_NAMESPACE::hash<T> x2;
|
||||||
|
@@ -23,8 +23,8 @@
|
|||||||
|
|
||||||
BOOST_AUTO_UNIT_TEST(pointer_tests)
|
BOOST_AUTO_UNIT_TEST(pointer_tests)
|
||||||
{
|
{
|
||||||
BOOST_CHECK(compile_time_tests<int*>::success);
|
compile_time_tests((int**) 0);
|
||||||
BOOST_CHECK(compile_time_tests<void*>::success);
|
compile_time_tests((void**) 0);
|
||||||
|
|
||||||
HASH_NAMESPACE::hash<int*> x1;
|
HASH_NAMESPACE::hash<int*> x1;
|
||||||
HASH_NAMESPACE::hash<int*> x2;
|
HASH_NAMESPACE::hash<int*> x2;
|
||||||
|
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
BOOST_AUTO_UNIT_TEST(string_tests)
|
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> x1;
|
||||||
HASH_NAMESPACE::hash<std::string> x2;
|
HASH_NAMESPACE::hash<std::string> x2;
|
||||||
@@ -34,7 +34,7 @@ BOOST_AUTO_UNIT_TEST(string_tests)
|
|||||||
#if !defined(BOOST_NO_STD_WSTRING)
|
#if !defined(BOOST_NO_STD_WSTRING)
|
||||||
BOOST_AUTO_UNIT_TEST(wstring_tests)
|
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> x1;
|
||||||
HASH_NAMESPACE::hash<std::wstring> x2;
|
HASH_NAMESPACE::hash<std::wstring> x2;
|
||||||
|
Reference in New Issue
Block a user