From d8323168530aaea57926c6031283d43b2dbf9858 Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Thu, 23 Mar 2017 06:20:18 +0000 Subject: [PATCH] Can't test for noexcept on C++03; std::hash isn't available until C++17 llvm-svn: 298580 --- libcxx/include/functional | 1 + .../test/std/utilities/function.objects/unord.hash/pointer.pass.cpp | 3 +++ libcxx/test/support/test_macros.h | 5 +++++ 3 files changed, 9 insertions(+) diff --git a/libcxx/include/functional b/libcxx/include/functional index 2a810b1..977ada6 100644 --- a/libcxx/include/functional +++ b/libcxx/include/functional @@ -470,6 +470,7 @@ template <> struct hash; template <> struct hash; template struct hash; +template <> struct hash; // C++17 } // std diff --git a/libcxx/test/std/utilities/function.objects/unord.hash/pointer.pass.cpp b/libcxx/test/std/utilities/function.objects/unord.hash/pointer.pass.cpp index d71514b..36280a3 100644 --- a/libcxx/test/std/utilities/function.objects/unord.hash/pointer.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/unord.hash/pointer.pass.cpp @@ -41,13 +41,16 @@ 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 H; static_assert((std::is_same::value), "" ); static_assert((std::is_same::value), "" ); ASSERT_NOEXCEPT(H()(T())); +#endif } int main() diff --git a/libcxx/test/support/test_macros.h b/libcxx/test/support/test_macros.h index 1db3f7f..3cde8cc 100644 --- a/libcxx/test/support/test_macros.h +++ b/libcxx/test/support/test_macros.h @@ -150,11 +150,16 @@ #define TEST_NORETURN [[noreturn]] #endif +#if TEST_STD_VER < 11 +#define ASSERT_NOEXCEPT(...) +#define ASSERT_NOT_NOEXCEPT(...) +#else #define ASSERT_NOEXCEPT(...) \ static_assert(noexcept(__VA_ARGS__), "Operation must be noexcept") #define ASSERT_NOT_NOEXCEPT(...) \ static_assert(!noexcept(__VA_ARGS__), "Operation must NOT be noexcept") +#endif /* Macros for testing libc++ specific behavior and extensions */ #if defined(_LIBCPP_VERSION) -- 2.7.4