GNOME Bugzilla – Bug 333931
support for smart pointers (dereference operator in template)
Last modified: 2012-07-22 16:29:54 UTC
Doxygen does not appear to understand dereference operators (->) in a templatised class as is typically used in smart pointers. I have encounterd the problem using boost::shared_ptr, but the following code illustrates the problem: template <class T> class SmartPointer { public: T *pointer; T *operator->() const {return pointer}; }; class A { public: void do() {}; }; class B { public: void do() {}; }; class C { public: A *a; SmartPointer<B> b; void do() { a->do(); b->do(); }; }; The doxygen output shows that a->do() is a reference to A::do(), but b->do() is unrecognised. This means that member function "Referenced by" lists are incomplete.
*** Bug 333997 has been marked as a duplicate of this bug. ***
*** Bug 334010 has been marked as a duplicate of this bug. ***
The collaboration diagram of class C appears correct with v1.4.6 in that SmartPointer<B> is associated with B::do(). However the call graph for C::do() is missing B::do(); and B:do() is missing 'referenced by' C::do().
Doxygen does not understand operator overloading at the moment.
Do you know roughly when operator overloading may be supported? I notice it is not on the wishlist, but I imagine it will benefit many people. Thanks.
Adding HELPWANTED keyword, as Dimitri has not set the ASSIGNED status. Rob: It will be implemented when some one chances by to fix it. Also, since doxygen is open source, you can also modify the source code yourself to support operator overloading. I think there are instructions in the doxygen manual on how to implement new stuff into the preprocessor.
Created attachment 183002 [details] [review] Patch to fix this bug This fixes this bug by adding support for operator ->() overloads. However smart pointers still don't work properly if they are declared using a typedef. CSmartPointer<CTest> pTest; typedef CSmartPointer<CTest> CTestPtr; CTestPtr pTest2; pTest->Func(); // Works pTest2->Func(); // Doesn't work.
In the meantime smart-pointer support has been added, so the original example works as expected. Feel free to reopen this bug report if you find a case where it does not work.