Merge pull request #374 from boostorg/has_hash

Update boost_has_hash.ipp tests for multiset.
This commit is contained in:
jzmaddock
2021-03-12 20:32:30 +00:00
committed by GitHub
2 changed files with 23 additions and 2 deletions

View File

@ -96,8 +96,8 @@
#if defined(__has_include)
#if defined(BOOST_HAS_HASH)
#if !__has_include(BOOST_HASH_SET_HEADER)
#undef BOOST_HAS_HAS
#if !__has_include(BOOST_HASH_SET_HEADER) || (__GNUC__ >= 10)
#undef BOOST_HAS_HASH
#undef BOOST_HAS_SET_HEADER
#undef BOOST_HAS_MAP_HEADER
#endif
@ -167,6 +167,16 @@
# define BOOST_LIBSTDCXX_VERSION 40300
#endif
#if (BOOST_LIBSTDCXX_VERSION >= 100000) && defined(BOOST_HAS_HASH)
//
// hash_set/hash_map deprecated and have terminal bugs:
//
#undef BOOST_HAS_HASH
#undef BOOST_HAS_SET_HEADER
#undef BOOST_HAS_MAP_HEADER
#endif
#if (BOOST_LIBSTDCXX_VERSION < 50100)
// libstdc++ does not define this function as it's deprecated in C++11, but clang still looks for it,
// defining it here is a terrible cludge, but should get things working:

View File

@ -26,6 +26,11 @@ void foo(const BOOST_STD_EXTENSION_NAMESPACE::hash_set<Key,Eq,Hash,Alloc>& )
{
}
template <class Key, class Eq, class Hash, class Alloc>
void foo(const BOOST_STD_EXTENSION_NAMESPACE::hash_multiset<Key,Eq,Hash,Alloc>& )
{
}
template <class Key, class T, class Eq, class Hash, class Alloc>
void foo(const BOOST_STD_EXTENSION_NAMESPACE::hash_map<Key,T,Eq,Hash,Alloc>& )
{
@ -37,9 +42,15 @@ int test()
{
#ifndef DISABLE_BOOST_HAS_HASH_TEST
BOOST_STD_EXTENSION_NAMESPACE::hash_set<int> hs;
hs.insert(2);
foo(hs);
BOOST_STD_EXTENSION_NAMESPACE::hash_map<int, long> hm;
hm[3] = 2;
foo(hm);
BOOST_STD_EXTENSION_NAMESPACE::hash_multiset<int> hs2;
hs2.insert(2);
hs2.insert(2);
foo(hs2);
#endif
return 0;
}