2222#include " test_macros.h"
2323#include " min_allocator.h"
2424
25- TEST_CONSTEXPR_CXX20 bool tests () {
25+ template <class VB >
26+ TEST_CONSTEXPR_CXX20 void test () {
2627 {
27- typedef std::vector< bool > T;
28+ typedef VB T;
2829 typedef std::hash<T> H;
2930#if TEST_STD_VER <= 14
3031 static_assert ((std::is_same<H::argument_type, T>::value), " " );
@@ -36,25 +37,17 @@ TEST_CONSTEXPR_CXX20 bool tests() {
3637 T vb (std::begin (ba), std::end (ba));
3738 H h;
3839 if (!TEST_IS_CONSTANT_EVALUATED) {
39- assert (h (vb) == h (vb));
40+ const std::size_t hash_value = h (vb);
41+ assert (h (vb) == hash_value);
42+ LIBCPP_ASSERT (hash_value != 0 );
4043 }
4144 }
45+ }
46+
47+ TEST_CONSTEXPR_CXX20 bool tests () {
48+ test<std::vector<bool > >();
4249#if TEST_STD_VER >= 11
43- {
44- typedef std::vector<bool , min_allocator<bool >> T;
45- typedef std::hash<T> H;
46- # if TEST_STD_VER <= 14
47- static_assert ((std::is_same<H::argument_type, T>::value), " " );
48- static_assert ((std::is_same<H::result_type, std::size_t >::value), " " );
49- # endif
50- ASSERT_NOEXCEPT (H ()(T ()));
51- bool ba[] = {true , false , true , true , false };
52- T vb (std::begin (ba), std::end (ba));
53- H h;
54- if (!TEST_IS_CONSTANT_EVALUATED) {
55- assert (h (vb) == h (vb));
56- }
57- }
50+ test<std::vector<bool , min_allocator<bool >>>();
5851#endif
5952
6053 return true ;
0 commit comments