Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using keyword on base class function brings the documentation into derived class #10843

Closed
scott-zhong opened this issue Apr 30, 2024 · 4 comments
Labels
bug C/C++ Usage The mentioned problem is not a doxygen problem but due to usage of a feature.

Comments

@scott-zhong
Copy link

Describe the bug
using keyword on base class function brings the documentation into derived class.

/**
 * Base docs
 */
class Base
{
public:
    /**
     * Base fun docs
     */
    void fun(int);
};

/**
 * Derived docs
 */
class Derived : public Base
{
public:
    using Base::fun;

    /**
     * Derived fun docs
     */
    void fun(double);
};

Screenshots
Doxygen 1.8.13
image

Doxygen 1.8.14 - trunk (85eb55d)
image

To Reproduce
testcase.zip

Expected behavior
Base function documentation shouldn't be in Derived class with using keyword

Version
Doxygen 1.8.14 - trunk (85eb55d)

@doxygen
Copy link
Owner

doxygen commented May 15, 2024

@scott-zhong I think the later versions of doxygen are actually (more) correct.

If I change your example to

#include <stdio.h>

/**
 * Base docs
 */
class Base
{
public:
    /**
     * Base fun docs
     */
    void fun(int v) { printf("Base::fun(%d)\n",v); }
};

/**
 * Derived docs
 */
class Derived : private Base
{
public:
    using Base::fun;

    /**
     * Derived fun docs
     */
    void fun(double d) { printf("Derived::fun(%f)\n",d); }
};


int main()
{
  Derived d;
  d.fun(10);
  d.fun(10.0);
}

The compiled program will print

Base::fun(10)
Derived::fun(10.000000)

Even though Base is a private base class of Derived, so the using statement brings the function into the public scope of Derived which is what doxygen shows.

@scott-zhong
Copy link
Author

@doxygen I disagree, using Base::fun does bring the Base's fun() into the scope of Derived, but should it be documented like Derived has defined the function? That is what it feels like if Base::fun is included in the Derived's API documentation (it is documented as both Derived's API and public member inherited from Base in 1.8.14 and later). I feel the previous documentation is more correct in that it is referring to see Base::fun for the documentation (Derived is merely exposing the API rather than defining it).

@doxygen
Copy link
Owner

doxygen commented May 21, 2024

@scott-zhong In your original example, you could simply omit the using statement to get the behavior you want. It doesn't do anything. In case where it does something (like changing the protection level in my example) I think the current behavior is better.

@scott-zhong
Copy link
Author

@doxygen That is certainly true. I am fine with closing this issue.

@doxygen doxygen closed this as completed May 29, 2024
@albert-github albert-github added the Usage The mentioned problem is not a doxygen problem but due to usage of a feature. label May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug C/C++ Usage The mentioned problem is not a doxygen problem but due to usage of a feature.
Projects
None yet
Development

No branches or pull requests

3 participants