diff mbox

[libstdc++] Add operator-> xmethod to std::unique_ptr

Message ID yjt2egn15vjc.fsf@ruffy.mtv.corp.google.com
State New
Headers show

Commit Message

Doug Evans April 30, 2015, 6:19 p.m. UTC
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->.

Comments

Jonathan Wakely April 30, 2015, 7:09 p.m. UTC | #1
On 30/04/15 11:19 -0700, Doug Evans wrote:
>Hi.
>
>This patch adds operator-> xmethod support for std::unique_ptr.
>
>Regression tested on amd64-linux.
>
>Ok to commit?

OK, thanks.
Doug Evans May 26, 2015, 11:09 p.m. UTC | #2
On Thu, Apr 30, 2015 at 12:09 PM, Jonathan Wakely <jwakely@redhat.com> wrote:
> On 30/04/15 11:19 -0700, Doug Evans wrote:
>>
>> Hi.
>>
>> This patch adds operator-> xmethod support for std::unique_ptr.
>>
>> Regression tested on amd64-linux.
>>
>> Ok to commit?
>
>
> OK, thanks.

Committed, thanks.
diff mbox

Patch

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
 }