This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] smart pointer support


The '->' operator can be overloaded in C++ and when overloaded it forwards the function call or member reference to the return type. Example:

template < typename Type> class SmartPointer{
  Type* p;
 public:
  SmartPointer(Type *pointer){
    p = pointer;
  }

  Type* operator->(){
    return p;
  }
};


class MyType{ public: void foo(){ printf("I am foo\n"); } };

int main(){
  MyType mt;

SmartPointer<MyType> sp(&mt);

sp->foo();

  return 0;
}

Here sp->foo() really means (sp->)->foo()

This patch adds support for that in gdb

This patch adds a test to the test suite to test for the functionality above and was regression tested by running the test suite on Fedora 13 on x8664 with gcc 444

Attachment: smart_pointer.patch
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]