G
Grahamo
Hi,
I have a question that pertains to Templates and link time. This is
totally for my own understanding and to correct what's obviously an
erroneous view of things on my behalf;
Lets say I have;
// main.cpp
template <classT>
class some_template
{
... details
};
int main(int argc, char** argv)
{
some_template<some_user_defined_type> goo;
}
now when I compile main.cpp the compiler is going to see that it needs
to generate an instance of some_template for some_user_defined_type".
It will then go ahead and compile up this generated code into a .obj
which can later be used at link time.
How can it be at link time I can get a link error for
"some_template<user_defined_type>::~some_template<user_defined_type> "
? I mean the compiler has already generated and compiled it up into the
object code and that is to be used by the linker. Assuming the linker
is using the correct .obj etc. what's missing that link errors can
arise like that? I would have thought that everything was generated by
the compiler. Or rather what's wrong with my understanding?
I have a question that pertains to Templates and link time. This is
totally for my own understanding and to correct what's obviously an
erroneous view of things on my behalf;
Lets say I have;
// main.cpp
template <classT>
class some_template
{
... details
};
int main(int argc, char** argv)
{
some_template<some_user_defined_type> goo;
}
now when I compile main.cpp the compiler is going to see that it needs
to generate an instance of some_template for some_user_defined_type".
It will then go ahead and compile up this generated code into a .obj
which can later be used at link time.
How can it be at link time I can get a link error for
"some_template<user_defined_type>::~some_template<user_defined_type> "
? I mean the compiler has already generated and compiled it up into the
object code and that is to be used by the linker. Assuming the linker
is using the correct .obj etc. what's missing that link errors can
arise like that? I would have thought that everything was generated by
the compiler. Or rather what's wrong with my understanding?