]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libstdc++-v3/testsuite/20_util/unique_ptr/hash/1.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 20_util / unique_ptr / hash / 1.cc
index d573a8ee90bc3b45a6d0d8f404df50f18864cc8c..dfe8a6945b44bee7692b0f2c0cfda58d212ee4f4 100644 (file)
@@ -1,8 +1,8 @@
-// { dg-options "-std=gnu++11" }
+// { dg-do run { target c++11 } }
 
 // 2010-06-11  Paolo Carlini  <paolo.carlini@oracle.com>
 
-// Copyright (C) 2010-2015 Free Software Foundation, Inc.
+// Copyright (C) 2010-2017 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
 
 #include <memory>
 #include <testsuite_hooks.h>
+#include <testsuite_allocator.h>
 
-void test01()
+// User-defined pointer type that throws if a null pointer is dereferenced.
+template<typename T>
+struct Pointer : __gnu_test::PointerBase<Pointer<T>, T>
+{
+};
+
+template<typename T>
+struct PointerDeleter : std::default_delete<T>
 {
-  bool test __attribute__((unused)) = true;
+  typedef Pointer<T> pointer;
+  void operator()(pointer) const;
+};
+
+template<class T>
+auto f(int) -> decltype(std::hash<std::unique_ptr<T,
+                       PointerDeleter<T>>>(), std::true_type());
 
+template<class T>
+auto f(...) -> decltype(std::false_type());
+
+static_assert(!decltype(f<Pointer<int>>(0))::value, "");
+
+void test01()
+{
   struct T { };
 
   std::unique_ptr<T>                                 u0(new T);