mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-21 23:30:38 +08:00
Can't test for noexcept on C++03; std::hash<nullptr_t> isn't available until C++17
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@298580 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -470,6 +470,7 @@ template <> struct hash<double>;
|
|||||||
template <> struct hash<long double>;
|
template <> struct hash<long double>;
|
||||||
|
|
||||||
template<class T> struct hash<T*>;
|
template<class T> struct hash<T*>;
|
||||||
|
template <> struct hash<nullptr_t>; // C++17
|
||||||
|
|
||||||
} // std
|
} // std
|
||||||
|
|
||||||
|
@@ -41,13 +41,16 @@ test()
|
|||||||
assert(h(&i) != h(&j));
|
assert(h(&i) != h(&j));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// can't hash nullptr_t until c++17
|
||||||
void test_nullptr()
|
void test_nullptr()
|
||||||
{
|
{
|
||||||
|
#if TEST_STD_VER > 14
|
||||||
typedef std::nullptr_t T;
|
typedef std::nullptr_t T;
|
||||||
typedef std::hash<T> H;
|
typedef std::hash<T> H;
|
||||||
static_assert((std::is_same<typename H::argument_type, T>::value), "" );
|
static_assert((std::is_same<typename H::argument_type, T>::value), "" );
|
||||||
static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
|
static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
|
||||||
ASSERT_NOEXCEPT(H()(T()));
|
ASSERT_NOEXCEPT(H()(T()));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
|
@@ -150,11 +150,16 @@
|
|||||||
#define TEST_NORETURN [[noreturn]]
|
#define TEST_NORETURN [[noreturn]]
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if TEST_STD_VER < 11
|
||||||
|
#define ASSERT_NOEXCEPT(...)
|
||||||
|
#define ASSERT_NOT_NOEXCEPT(...)
|
||||||
|
#else
|
||||||
#define ASSERT_NOEXCEPT(...) \
|
#define ASSERT_NOEXCEPT(...) \
|
||||||
static_assert(noexcept(__VA_ARGS__), "Operation must be noexcept")
|
static_assert(noexcept(__VA_ARGS__), "Operation must be noexcept")
|
||||||
|
|
||||||
#define ASSERT_NOT_NOEXCEPT(...) \
|
#define ASSERT_NOT_NOEXCEPT(...) \
|
||||||
static_assert(!noexcept(__VA_ARGS__), "Operation must NOT be noexcept")
|
static_assert(!noexcept(__VA_ARGS__), "Operation must NOT be noexcept")
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Macros for testing libc++ specific behavior and extensions */
|
/* Macros for testing libc++ specific behavior and extensions */
|
||||||
#if defined(_LIBCPP_VERSION)
|
#if defined(_LIBCPP_VERSION)
|
||||||
|
Reference in New Issue
Block a user