J
James Kanze
But would answer the original question of "How can you force
instantiation of a Template?"
What does it mean to "force instantiation of a template"?
-- The compiler will instantiate a template implicitly, when
needed. I can "force" it to instantiate the template, even
if not otherwise needed, by requesting explicit
instantiation.
-- I can request explicit instantiation of a template. I can
force the compiler to instantiate it even in the absence of
such a request simply by using it in certain ways.
-- The compiler never instantiates a template without a reason:
I either have to explicitly request it, or use it in some
way which triggers instantiation. In other words, a
template is never instantiated unless the compiler is
"forced" to do so.
The question, as worded, is an example of sloppiness and
imprecision. Computer science, software engineering, and
programming in general are activities requiring a enormous
amount of order and precision. The only possible use of a
question like this would be as a trick question: any simple
response shows that you missed the ambiguity, and perhaps don't
possess enough order and precision to be competent in the field.
The problem with such trick questions, however, is that a simple
response might simply be that you're used to dealing with
management types who don't possess order and precision, and know
how to exterpolate what they probably mean from what they
actually said. In most cases, for example, I'm willing to bet
that the first answer above was the one the interviewer was
actually looking for.
Depending on the role the interviewer has in the organization,
such questions might make me wonder about whether I want to work
there or not. (If it's someone in DHR, it's more or less what
I'd expecct---if it's supposedly the technical lead, on the
other hand...)