Hash: Only use typeid when available.

[SVN r78755]
This commit is contained in:
Daniel James
2012-05-29 19:41:19 +00:00
parent 446b6496a7
commit b839b806cf

View File

@@ -18,12 +18,16 @@
#include <typeindex> #include <typeindex>
void test_type_index() { void test_type_index() {
HASH_NAMESPACE::hash<std::type_index> hasher;
#if defined(BOOST_NO_TYPEID)
std::cout<<"Unable to test std::type_index, as typeid isn't available"
<<std::endl;
#else
std::type_index int_index = typeid(int); std::type_index int_index = typeid(int);
std::type_index int2_index = typeid(int); std::type_index int2_index = typeid(int);
std::type_index char_index = typeid(char); std::type_index char_index = typeid(char);
HASH_NAMESPACE::hash<std::type_index> hasher;
BOOST_TEST(hasher(int_index) == int_index.hash_code()); BOOST_TEST(hasher(int_index) == int_index.hash_code());
BOOST_TEST(hasher(int_index) == int2_index.hash_code()); BOOST_TEST(hasher(int_index) == int2_index.hash_code());
BOOST_TEST(hasher(char_index) == char_index.hash_code()); BOOST_TEST(hasher(char_index) == char_index.hash_code());
@@ -33,6 +37,7 @@ void test_type_index() {
BOOST_TEST(hasher(int_index) == hasher(int2_index)); BOOST_TEST(hasher(int_index) == hasher(int2_index));
BOOST_TEST(hasher(int_index) != hasher(char_index)); BOOST_TEST(hasher(int_index) != hasher(char_index));
#endif
} }
#endif #endif