|
![](/i/fill.gif) |
Darren New <dne### [at] san rr com> wrote:
> For example, you have to parse and compile the
> templates each time from source
A compiler which supports export templates could conceivably have
precompiled templates for certain (although obviously not all) types,
such as for example for all basic types and STL classes. Thus it could
avoid having to compile them each time.
> and you get a new blob of code for each
> type you instantiate a template with.
If you are using the same code with two different types you are obviously
going to get two different pieces of code, no matter how you do it.
Templates just make it easier to avoid code repetition. (In other words,
if you want, for example, a vector of ints and a vector of doubles, you
don't need to write the vector code twice.)
Templated data containers in C++ usually produce more memory-efficient
code than equivalent data containers using the pointer-to-base-Object
mechanism, which usually wastes a lot of memory. Thus any argument that
templates cause memory bloat is usually false. (Yes, there may be a few
situations where templated code causes more memory usage, but normally
it's the opposite.)
> Now, "crippled" is what I'd call the baroque C++ syntax.
Syntax doesn't really matter all that much. It's how you use it.
--
- Warp
Post a reply to this message
|
![](/i/fill.gif) |