Recently, when I was trying to optimize my include hierarchy, I came across a file a.hpp:
template<class T>
class A
{
using t = typename T::a_t;
};
class B;
extern template class A<B>;
which seems to be poorly formed. Actually, it seems that the extern template expression at the end invokes an instance A<B>that causes the compiler to complain about an incomplete type.
My goal would be to define A<B>in a.cpp:
#include <b.hpp>
template class A<B>;
Thus, I should not include b.hppfrom a.hpp, which seems like a good idea to reduce compilation time. However, it does not work ( a.hppit does not compile by itself!) Is there a better way to do this?
. , , , ! " " A<B>, , , A<B> , b.hpp , a.hpp!