You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
cppclean seems to be clever enough to determine that you can have a
std::shared_ptr<X>
to a forward-declared typeX
, 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:For this case, cppclean prints:
On the other hand, if you change the line
MySharedPtr<X> x;
to simplystd::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.The text was updated successfully, but these errors were encountered: