为什么模板基类不被强制实例化

Ozn*_*nOg 6 c++ templates

我有 2 个模板类,一个从另一个继承。

template <class T>
class X {
    public:
    int get() { return 1; }
};

template <class T>
class B : public X<T> {};

// Force B instantiation would expect X to be forced as well
template class B<int>;

// If I remove next line, no code is emitted for X
template class X<int>
Run Code Online (Sandbox Code Playgroud)

当强制 B 的模板实例化时,X 也不会被实例化(请参阅https://godbolt.org/z/3vvenM8j4

这是什么原因呢?

注意:这是如何强制实例化与类型别名一起使用的模板类的后续内容

我希望给定的解决方案能够工作,但事实并非如此