Christopher Smith wrote:
Darren New wrote:
Christopher Smith wrote:
Hmmm... Maybe, yah. I suspect you'd still have to inline both of those
for that to work.
Fortunately... that decision is up to the optimizer. ;-)
I thought C++ required you to change the source code if you wanted
object code inlined, yes? I would think it exceptionally difficult
to inline code that isn't in the .h file included in the source
that's being compiled, yes? If it's already compiled and in a
library, how would the optimizer know you're getting the same value
as the check is using?
The "inline" keyword is strictly a hint, much like the "register"
keyword.
Oh, and the beauty/horror of templates is that they get instantiated
by the compiler as it uses them. In a sense they are like type-aware
macros. You can have specific instantiations made available in a
library, but people typically only tend to do that with the STL
(because certain instances are so often used).
Actually, come to think of it, it is entirely possible that even with a
dynamically linked library that inlining a redundant code elimination
could happen. Herb Sutter wrote an excellent article on this a while back.
http://www.ddj.com/dept/cpp/184403879
--Chris
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg