Re: template function definition in cpp file
Helmut Zeisel wrote:
On 24 Apr., 18:04, "Victor Bazarov" <v.Abaza...@comAcast.net> wrote:
The Standard requires the _definition_
to *exist*. And since the Standard only talks of the source form,
then yes, the source form *has to exists somewhere*. Do you have
to give it to the compiler/linker every time you build your 'main'
program in the *source form*? Usually no.
Up to now I had the impression that if I deliver a template interface
to a customer I also have to deliver the template definition. As I now
understand this is not true. It is possible just to deliver some
instantiations without source. Of course, however, it is not possible
for the customer to create additional instantiations.
That's a good way to put it. If you want the user of your class to
limit their use to a specific set of template arguments, you provide
the declarations of the functions and a binary library that contains
the definitions (from explicit instantiations or specialisations of
the template) of those functions, without the source code. Of course
nothing prevents the user from trying to provide their own code that
would specialise the template based on their own template argument[s].
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask