public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Doug Evans <dje@google.com>
To: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org
Subject: [PATCH] [libstdc++] Add operator-> xmethod to std::unique_ptr
Date: Thu, 30 Apr 2015 18:36:00 -0000	[thread overview]
Message-ID: <yjt2egn15vjc.fsf@ruffy.mtv.corp.google.com> (raw)

Hi.

This patch adds operator-> xmethod support for std::unique_ptr.

Regression tested on amd64-linux.

Ok to commit?

2015-04-30  Doug Evans  <dje@google.com>

	* python/libstdcxx/v6/xmethods.py (UniquePtrMethodsMatcher): Add
	operator-> support.
	* testsuite/libstdc++-xmethods/unique_ptr.cc: Add tests for
	operator->.

Index: python/libstdcxx/v6/xmethods.py
===================================================================
--- python/libstdcxx/v6/xmethods.py	(revision 222651)
+++ python/libstdcxx/v6/xmethods.py	(working copy)
@@ -584,6 +584,7 @@
                                             matcher_name_prefix + 'unique_ptr')
         self._method_dict = {
             'get': LibStdCxxXMethod('get', UniquePtrGetWorker),
+            'operator->': LibStdCxxXMethod('operator->', UniquePtrGetWorker),
             'operator*': LibStdCxxXMethod('operator*', UniquePtrDerefWorker),
         }
         self.methods = [self._method_dict[m] for m in self._method_dict]
Index: testsuite/libstdc++-xmethods/unique_ptr.cc
===================================================================
--- testsuite/libstdc++-xmethods/unique_ptr.cc	(revision 222651)
+++ testsuite/libstdc++-xmethods/unique_ptr.cc	(working copy)
@@ -20,13 +20,22 @@
 
 #include <memory>
 
+struct x_struct
+{
+  int y;
+};
+
 int
 main ()
 {
   int *i = new int;
   *i = 10;
+  std::unique_ptr<int> p(i);
 
-  std::unique_ptr<int> p(i);
+  x_struct *x = new x_struct;
+  x->y = 23;
+  std::unique_ptr<x_struct> q(x);
+
 // { dg-final { note-test *p 10 } }
 // { dg-final { regexp-test p.get() 0x.* } }
 
@@ -33,6 +42,14 @@
 // { dg-final { whatis-test *p int } }
 // { dg-final { whatis-test p.get() "int \*" } }
 
+// { dg-final { note-test *q {\{y = 23\}} } }
+// { dg-final { regexp-test q.get() 0x.* } }
+// { dg-final { note-test q->y 23 } }
+
+// { dg-final { whatis-test *q x_struct } }
+// { dg-final { whatis-test q.get() "x_struct \*" } }
+// { dg-final { whatis-test q->y int } }
+
   return 0;  // Mark SPOT
 }
 

             reply	other threads:[~2015-04-30 18:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-30 18:36 Doug Evans [this message]
2015-04-30 19:24 ` Jonathan Wakely
2015-05-27  5:22   ` Doug Evans

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=yjt2egn15vjc.fsf@ruffy.mtv.corp.google.com \
    --to=dje@google.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).