|
![](/i/fill.gif) |
Le_Forgeron <lef### [at] free fr> wrote:
> If they are in separate compilation units (different top level *.cpp
> files), each units will get its own version.
No, they will be merged by the linker (although I'm not completely sure
now if the standard requires it; at the very least it requires for all
static variables inside the function to be merged, IIRC).
If the context of the template instantiation affects its behavior, then
instantiating it under differing contexts is actually undefined behavior.
(In practice what will usually happen is that only one of them will end up
in the final binary and all the code will call that one; the other contexts
will have no effect on it.)
> (that's the issue with template: generated code can grow very fast if
> you use the template in many *.cpp files)
Object files might grow, but not the final binary.
--
- Warp
Post a reply to this message
|
![](/i/fill.gif) |