Bjørn Augestad said:
Logan Shaw wrote:
No size overhead either?
Nope, no size overhead, because the equivalent thing is to implement
a set of functions twice, once for each type that must be dealt with.
Whether you do this manually in C or have the compiler do it for you
automatically in C++, it still results in two chunks of object code
that are very similar.
Granted, it's not all that often that you encounter a situation
where you need to do that, but it can happen, and C++ could make
your life easier in that case, without reducing the performance
or increasing the size of the executable.
I realize this is not a common problem, but my whole point here is
this: most people already agree that putting the same code through
a C and a C++ compiler will result in similar speeds in the output.
I am just trying to establish that it is possible to have similar
speed (and code size) when using some C++-only features. Once
that is established, there is no argument that using C++ leads to
bad performance; it becomes an argument against using certain slow
C++ features leads to bad performance, not an argument against C++
in general.
Also, I apologize for my poor malloc() style that about 10 people
pointed out.
Obviously, I've gotten into a habit of doing it
in a bad way. I think it may be because I ran into a compiler that
would only allow the type name in sizeof() years ago, although that
is obviously not a good reason to keep doing it...
- Logan