| 1 | // Copyright 2022 Peter Dimov. |
|---|---|
| 2 | // Distributed under the Boost Software License, Version 1.0. |
| 3 | // https://www.boost.org/LICENSE_1_0.txt |
| 4 | |
| 5 | #include <boost/container_hash/hash.hpp> |
| 6 | #include <boost/core/lightweight_test_trait.hpp> |
| 7 | #include <boost/unordered/hash_traits.hpp> |
| 8 | #include <boost/config.hpp> |
| 9 | #include <string> |
| 10 | |
| 11 | enum my_char { min = 0, max = 255 }; |
| 12 | |
| 13 | int main() |
| 14 | { |
| 15 | using boost::unordered::hash_is_avalanching; |
| 16 | |
| 17 | BOOST_TEST_TRAIT_TRUE(( hash_is_avalanching< boost::hash<std::string> > )); |
| 18 | BOOST_TEST_TRAIT_TRUE(( hash_is_avalanching< boost::hash<std::wstring> > )); |
| 19 | |
| 20 | #if !defined(BOOST_NO_CXX11_CHAR16_T) |
| 21 | |
| 22 | BOOST_TEST_TRAIT_TRUE(( hash_is_avalanching< boost::hash<std::u16string> > )); |
| 23 | |
| 24 | #endif |
| 25 | |
| 26 | #if !defined(BOOST_NO_CXX11_CHAR32_T) |
| 27 | |
| 28 | BOOST_TEST_TRAIT_TRUE(( hash_is_avalanching< boost::hash<std::u32string> > )); |
| 29 | |
| 30 | #endif |
| 31 | |
| 32 | #if defined(__cpp_char8_t) && __cpp_char8_t >= 201811L |
| 33 | |
| 34 | BOOST_TEST_TRAIT_TRUE(( hash_is_avalanching< boost::hash< std::basic_string<char8_t> > > )); |
| 35 | |
| 36 | #endif |
| 37 | |
| 38 | #if defined(_LIBCPP_VERSION) && _LIBCPP_VERSION >= 160000 |
| 39 | // std::char_traits<Ch> is deprecated for non-char types |
| 40 | #else |
| 41 | BOOST_TEST_TRAIT_FALSE(( hash_is_avalanching< boost::hash<std::basic_string<my_char> > > )); |
| 42 | #endif |
| 43 | |
| 44 | return boost::report_errors(); |
| 45 | } |
| 46 |
