summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/experimental/memory/observer_ptr/make_observer.cc
diff options
context:
space:
mode:
authorVille Voutilainen <ville.voutilainen@gmail.com>2015-05-02 00:01:11 +0300
committerJonathan Wakely <redi@gcc.gnu.org>2015-05-01 22:01:11 +0100
commit261b7e8af2d8d2c3b89132824625d0fa91972338 (patch)
tree977fd4fdf0dfaa7845341f7dfc8aaf1f86672a0f /libstdc++-v3/testsuite/experimental/memory/observer_ptr/make_observer.cc
parent4ad376273d70e96e1b7d3eac126c3e1598246d5c (diff)
downloadgcc-261b7e8af2d8d2c3b89132824625d0fa91972338.tar.gz
Implement observer_ptr.
2015-05-01 Ville Voutilainen <ville.voutilainen@gmail.com> Implement observer_ptr. * include/Makefile.am: Add new header. * include/Makefile.in: Regenerate. * include/experimental/memory: New. * testsuite/experimental/memory/observer_ptr/assignment/assign.cc: New. * testsuite/experimental/memory/observer_ptr/cons/cons.cc: New. * testsuite/experimental/memory/observer_ptr/hash/hash.cc: New. * testsuite/experimental/memory/observer_ptr/make_observer.cc: New. * testsuite/experimental/memory/observer_ptr/relops/relops.cc: New. * testsuite/experimental/memory/observer_ptr/requirements.cc: New. * testsuite/experimental/memory/observer_ptr/swap/swap.cc: New. * testsuite/experimental/memory/observer_ptr/typedefs.cc: New. From-SVN: r222706
Diffstat (limited to 'libstdc++-v3/testsuite/experimental/memory/observer_ptr/make_observer.cc')
-rw-r--r--libstdc++-v3/testsuite/experimental/memory/observer_ptr/make_observer.cc32
1 files changed, 32 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/experimental/memory/observer_ptr/make_observer.cc b/libstdc++-v3/testsuite/experimental/memory/observer_ptr/make_observer.cc
new file mode 100644
index 00000000000..b6075fab9c3
--- /dev/null
+++ b/libstdc++-v3/testsuite/experimental/memory/observer_ptr/make_observer.cc
@@ -0,0 +1,32 @@
+// { dg-options "-std=gnu++14" }
+// { dg-do run }
+
+// Copyright (C) 2015 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a moved_to of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/memory>
+#include <testsuite_hooks.h>
+
+int main()
+{
+ const int i = 42;
+ auto o = std::experimental::make_observer(&i);
+ static_assert( std::is_same<decltype(o),
+ std::experimental::observer_ptr<const int>>(), "" );
+ VERIFY( o && *o == 42 );
+ VERIFY( o.get() == &i );
+}