3 ms·
Hello. Forgive my ignorance and possible misunderstanding of your 'most code' qualifier. If I have a template header .hpp and I do not wish to specialize the t
by eliasmacpherson 4y ago
Hello. Forgive my ignorance and possible misunderstanding of your 'most code' qualifier.
If I have a template header .hpp and I do not wish to specialize the template function bodies in a .cpp file, the template header function bodies must be declared in the .hpp, right?
- pjmlp 4y agoYes and no. Yes it needs to be on the header, however depending on what is the goal, many operations could eventually be delegated to helper functions or PIMPL classes, which aren't fully exposed on the header. And for the lucky users of VC++ 2022, there is also the option to use modules instead, where templates are then exposed via the module metada.
- eliasmacpherson 4y agoHelper functions, PIMPL, that's all fine - the declaration and function body of the template is still defined in the .hpp. Whether all of the body of the template is also defined there was not my concern in asking. Thanks for your comment. I will have to dig in to modules in due course.