[libcxx] r298580 - Can't test for noexcept on C++03; std::hash<nullptr_t> isn't available until C++17

Marshall Clow via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 22 23:20:18 PDT 2017


Author: marshall
Date: Thu Mar 23 01:20:18 2017
New Revision: 298580

URL: http://llvm.org/viewvc/llvm-project?rev=298580&view=rev
Log:
Can't test for noexcept on C++03; std::hash<nullptr_t> isn't available until C++17

Modified:
    libcxx/trunk/include/functional
    libcxx/trunk/test/std/utilities/function.objects/unord.hash/pointer.pass.cpp
    libcxx/trunk/test/support/test_macros.h

Modified: libcxx/trunk/include/functional
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/functional?rev=298580&r1=298579&r2=298580&view=diff
==============================================================================
--- libcxx/trunk/include/functional (original)
+++ libcxx/trunk/include/functional Thu Mar 23 01:20:18 2017
@@ -470,6 +470,7 @@ template <> struct hash<double>;
 template <> struct hash<long double>;
 
 template<class T> struct hash<T*>;
+template <> struct hash<nullptr_t>;  // C++17
 
 }  // std
 

Modified: libcxx/trunk/test/std/utilities/function.objects/unord.hash/pointer.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/unord.hash/pointer.pass.cpp?rev=298580&r1=298579&r2=298580&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/unord.hash/pointer.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/function.objects/unord.hash/pointer.pass.cpp Thu Mar 23 01:20:18 2017
@@ -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<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()

Modified: libcxx/trunk/test/support/test_macros.h
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/test_macros.h?rev=298580&r1=298579&r2=298580&view=diff
==============================================================================
--- libcxx/trunk/test/support/test_macros.h (original)
+++ libcxx/trunk/test/support/test_macros.h Thu Mar 23 01:20:18 2017
@@ -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)




More information about the cfe-commits mailing list