What is meant with “deferred instantiation” in C++ templates?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Deferred instantiation is when the template is not instantiated until the corresponding entity is used for the first time. For example, you have a templated function:
parameter
Sizecan have any possible value thatintcan have. Do you automatically have the templated function instantiated for all possible values ofSize? No, the template is only instantiated for the values that are actually used as the parameter when the function call first appears in the code: