class template instantiation

前端 未结 2 856
心在旅途
心在旅途 2020-12-06 01:09

I just read the wiki article about CRTP, and I\'m a little confused about template instantiation.

According to the wiki,

member function bodi

2条回答
  •  粉色の甜心
    2020-12-06 02:10

    With class templates, the rule of thumb is that only those members are instantiated which are actually used.

    If you want complete instantiation, C++ offers explicit instantiation (however, usually you don't; the fact that not every bit is fully instantiated means that your template class is even more generic as it lowers the requirements on T, note that syntax checking and lookup of non-dependent types (stuff that is not dependent on T) still happens).

    You will find a more complete answer here: Template instantiation details of GCC and MS compilers

提交回复
热议问题