libc++ implements its' hash objects as deriving from std::unary_function, and the...
authorMarshall Clow <mclow.lists@gmail.com>
Wed, 7 Jan 2015 21:53:23 +0000 (21:53 +0000)
committerMarshall Clow <mclow.lists@gmail.com>
Wed, 7 Jan 2015 21:53:23 +0000 (21:53 +0000)
llvm-svn: 225403

libcxx/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp
libcxx/test/std/diagnostics/syserr/syserr.hash/error_code.pass.cpp
libcxx/test/std/experimental/string.view/string.view.hash/string_view.pass.cpp
libcxx/test/std/strings/basic.string.hash/strings.pass.cpp
libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/thread_id.pass.cpp
libcxx/test/std/utilities/function.objects/unord.hash/enum.pass.cpp
libcxx/test/std/utilities/function.objects/unord.hash/floating.pass.cpp
libcxx/test/std/utilities/function.objects/unord.hash/integral.pass.cpp
libcxx/test/std/utilities/function.objects/unord.hash/pointer.pass.cpp
libcxx/test/std/utilities/template.bitset/bitset.hash/bitset.pass.cpp
libcxx/test/std/utilities/type.index/type.index.synopsis/hash_type_index.pass.cpp

index ea2262c..a78f4fd 100644 (file)
@@ -29,8 +29,9 @@ int main()
     {
     typedef std::vector<bool> T;
     typedef std::hash<T> H;
-    static_assert((std::is_base_of<std::unary_function<T, std::size_t>,
-                                   H>::value), "");
+    static_assert((std::is_same<H::argument_type, T>::value), "" );
+    static_assert((std::is_same<H::result_type, std::size_t>::value), "" );
+    
     bool ba[] = {true, false, true, true, false};
     T vb(std::begin(ba), std::end(ba));
     H h;
index 14d7b2d..b812e36 100644 (file)
@@ -27,8 +27,8 @@ test(int i)
 {
     typedef std::error_code T;
     typedef std::hash<T> H;
-    static_assert((std::is_base_of<std::unary_function<T, std::size_t>,
-                                   H>::value), "");
+    static_assert((std::is_same<H::argument_type, T>::value), "" );
+    static_assert((std::is_same<H::result_type, std::size_t>::value), "" );
     H h;
     T ec(i, std::system_category());
     assert(h(ec) == i);
index 03e0db2..6b16971 100644 (file)
@@ -29,8 +29,8 @@ void
 test()
 {
     typedef std::hash<T> H;
-    static_assert((std::is_base_of<std::unary_function<T, std::size_t>,
-                                   H>::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), "" );
     H h;
 //     std::string g1 = "1234567890";
 //     std::string g2 = "1234567891";
index 8ba166f..5fc32c0 100644 (file)
@@ -27,8 +27,8 @@ void
 test()
 {
     typedef std::hash<T> H;
-    static_assert((std::is_base_of<std::unary_function<T, std::size_t>,
-                                   H>::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), "" );
     H h;
     std::string g1 = "1234567890";
     std::string g2 = "1234567891";
index bb7f2aa..106c69e 100644 (file)
@@ -28,6 +28,8 @@ int main()
     std::thread::id id1;
     std::thread::id id2 = std::this_thread::get_id();
     typedef std::hash<std::thread::id> H;
+    static_assert((std::is_same<typename H::argument_type, std::thread::id>::value), "" );
+    static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
     H h;
     assert(h(id1) != h(id2));
 }
index b5cd6f8..4dbd7b0 100644 (file)
@@ -33,11 +33,12 @@ template <class T>
 void
 test()
 {
-    static_assert((std::is_base_of<std::unary_function<T, std::size_t>,
-                                   std::hash<T> >::value), "");
+    typedef std::hash<T> H;
+    static_assert((std::is_same<H::argument_type, T>::value), "" );
+    static_assert((std::is_same<H::result_type, std::size_t>::value), "" );
     typedef typename std::underlying_type<T>::type under_type;
     
-    std::hash<T> h1;
+    H h1;
     std::hash<under_type> h2;
     for (int i = 0; i <= 5; ++i)
     {
index 988950d..f1f198f 100644 (file)
@@ -28,9 +28,11 @@ template <class T>
 void
 test()
 {
-    static_assert((std::is_base_of<std::unary_function<T, std::size_t>,
-                                   std::hash<T> >::value), "");
-    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::result_type, std::size_t>::value), "" );
+    H h;
+
     std::size_t t0 = h(0.);
     std::size_t tn0 = h(-0.);
     std::size_t tp1 = h(0.1);
index e5f7ca6..7cd9f15 100644 (file)
@@ -27,9 +27,11 @@ template <class T>
 void
 test()
 {
-    static_assert((std::is_base_of<std::unary_function<T, std::size_t>,
-                                   std::hash<T> >::value), "");
-    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::result_type, std::size_t>::value), "" );
+    H h;
+
     for (int i = 0; i <= 5; ++i)
     {
         T t(i);
index e4e0112..a483944 100644 (file)
@@ -27,9 +27,11 @@ template <class T>
 void
 test()
 {
-    static_assert((std::is_base_of<std::unary_function<T, std::size_t>,
-                                   std::hash<T> >::value), "");
-    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::result_type, std::size_t>::value), "" );
+    H h;
+
     typedef typename std::remove_pointer<T>::type type;
     type i;
     type j;
index b1b24f9..520f2e8 100644 (file)
@@ -28,8 +28,8 @@ test()
 {
     typedef std::bitset<N> T;
     typedef std::hash<T> H;
-    static_assert((std::is_base_of<std::unary_function<T, std::size_t>,
-                                   H>::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), "" );
     H h;
     T bs(static_cast<unsigned long long>(N));
     assert(h(bs) == N);
index b855d12..6d353f1 100644 (file)
@@ -20,6 +20,7 @@
 
 int main()
 {
-    static_assert((std::is_base_of<std::unary_function<std::type_index, std::size_t>,
-                                   std::hash<std::type_index> >::value), "");
+    typedef std::hash<std::type_index> H;
+    static_assert((std::is_same<typename H::argument_type, std::type_index>::value), "" );
+    static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
 }