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

Incomplete type, std::shared_ptr, and alias declaration #87

Open
jwpeterson opened this issue Jan 5, 2016 · 0 comments
Open

Incomplete type, std::shared_ptr, and alias declaration #87

jwpeterson opened this issue Jan 5, 2016 · 0 comments

Comments

@jwpeterson
Copy link

cppclean seems to be clever enough to determine that you can have a std::shared_ptr<X> to a forward-declared type X, which is good.

Unfortunately, if the name is hidden behind an alias declaration, cppclean then warns that X must be #included. The following test code demonstrates the issue:

#include <memory>

// Forward declaration of class X is all that is required to have a std::shared_ptr
class X;

// Alias declaration - requires C++11
template<typename T>
using MySharedPtr = std::shared_ptr<T>;

struct A
{
  MySharedPtr<X> x;
};

For this case, cppclean prints:

cppclean_test5.h:4: 'X' forward declared, but needs to be #included

On the other hand, if you change the line MySharedPtr<X> x; to simply std::shared_ptr<X> x;, the warning goes away. So I guess this is really more of a feature request to better handle alias declarations, as we use this technique to handle backwards compatibility with older compilers in our library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant