it's ok if I write class param as a template class.
struct fwd;
template <class T>
class param
{
public:
void callinit()
{
p = std::make_shared<T>();
}
std::shared_ptr<T> p{nullptr};
};
param<fwd> pf;
but it will fail when the class param is not a template class: error: invalid application of 'sizeof' to incomplete type 'fwd' : std::aligned_storage<sizeof(_Tp), std::alignment_of<_Tp>::value> ^~~~~~~~~~
struct fwd;
class param
{
public:
void callinit()
{
p = std::make_shared<fwd>();
}
std::shared_ptr<fwd> p{nullptr};
};
param pf;
actually the header file fwd.hpp never included in both of two conditions, but why the first condition succeed, but second failed?