Revert "Revert "Merge to upstream r304942.""
This reverts commit 38a0d5af7e.
Test: make checkbuild
Test: ./run_tests.py
Test: ./run_tests.py --bitness 64
This commit is contained in:
@@ -23,6 +23,8 @@
|
||||
#include <type_traits>
|
||||
#include <limits>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class T>
|
||||
void
|
||||
test()
|
||||
@@ -30,6 +32,7 @@ test()
|
||||
typedef std::hash<T> H;
|
||||
static_assert((std::is_same<typename H::argument_type, T>::value), "" );
|
||||
static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
|
||||
ASSERT_NOEXCEPT(H()(T()));
|
||||
H h;
|
||||
|
||||
typedef typename std::remove_pointer<T>::type type;
|
||||
@@ -38,7 +41,20 @@ test()
|
||||
assert(h(&i) != h(&j));
|
||||
}
|
||||
|
||||
// can't hash nullptr_t until c++17
|
||||
void test_nullptr()
|
||||
{
|
||||
#if TEST_STD_VER > 14
|
||||
typedef std::nullptr_t T;
|
||||
typedef std::hash<T> H;
|
||||
static_assert((std::is_same<typename H::argument_type, T>::value), "" );
|
||||
static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
|
||||
ASSERT_NOEXCEPT(H()(T()));
|
||||
#endif
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<int*>();
|
||||
test_nullptr();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user