次のテンプレート クラスが、ほとんどがint型名のプロジェクトで頻繁に使用され、このクラスの導入以降、リンカの速度が著しく低下したとします。
template <typename T>
class MyClass
{
void Print()
{
std::cout << m_tValue << std::endl;;
}
T m_tValue;
}
クラスの特殊化を定義すると、コンパイル速度が向上しますか? 例えば。
template <>
class MyClass<int>
{
void Print()
{
std::cout << m_tValue << std::endl;;
}
int m_tValue;
}
または、明示的なインスタンス化はより良い解決策を提供しますか? 例えば。
template class MyClass<int>;