I'm learning C++ via C++ Primer Plus, Fifth Edition and I'm having trouble understanding the differences between implicit instantiation and explicit instantiation.
To quote from the book:
This sentence in particular is confusing:This type of instantiation is termed implicit instantiation because the compiler deduces the necessity for making the definition by nothing that the program uses a Swap() function with int parameters.
Originally, using implicit instantiation was the only way the compiler generated function definitions from templates, but now C++ allows for explicit instantiation. That means you can instruct the compiler to create a particular instantiation--for example, Swap<int>()--directly.
What is the advantage of this?That means you can instruct the compiler to create a particular instantiation
Can anyone explain this or provide urls to a thorough explanation and more importantly, why one is more important than the other?
Man, this template stuff is tough!