mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-22 07:51:39 +08:00
Implement P0599: 'noexcept for hash functions'. Fix a couple of hash functions (optional<T> and unique_ptr<T>) which were mistakenly marked as 'noexcept'. Reviewed as https://reviews.llvm.org/D31234
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@298573 91177308-0d34-0410-b5e6-96231b3b80d8
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,17 @@ test()
|
||||
assert(h(&i) != h(&j));
|
||||
}
|
||||
|
||||
void test_nullptr()
|
||||
{
|
||||
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()));
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<int*>();
|
||||
test_nullptr();
|
||||
}
|
||||
|
Reference in New Issue
Block a user