views:

177

answers:

6

I think I can sum up the use of generics in Java in one word: type-safety. Can you conclude the use of templates in C++ in one word, please?

+2  A: 

C++ Templates: code generators. (two words)

Pablo Santa Cruz
How about code-generators?
Stephen Swensen
@Stephen: hehehehehehehehe... G1!
Pablo Santa Cruz
A: 

Since hyphens are evidently allowed, 'generic-programming'. Note that 'generic' in this context does not have quite the same meaning as it does in Java generics. Java generics are really a different name for parametric polymorphism; the generic programming facilitated by C++ templates goes beyond what is allowed by parametric polymorphism.

Michael E
If you have to explain what you mean by your word, it's no longer one word, is it? ;) Not that I think describing something like this in one word would be useful to anyone.
PigBen
A: 

c++ templates: templates. Its tautological, but since we are restricted to one word, Templates is as complete a one I can think of...

hvgotcodes
+4  A: 

One word: Meta-programming.

But really, what you're asking is very difficult. Templates are a complex topic. At heart, templates are facilities for meta-programming: that is, they're code which generates more code.

In the real word, templates are used most often to generate multiple classes or functions from the same class/function template, each of which is used with different type parameters. In other words, generic-programming. This is probably best showcased by the container classes in the STL.

But because templates are ultimately a meta-programming facility, they do more than just allow you to implement generic classes/functions. Specialization, partial specialization, and SFINAE allows for a whole range of code-generation abilities that goes well beyond implementing generic classes or functions. In fact, recursive template instantiation allows you to program using a Turing-complete meta-language embedded within C++.

Charles Salvia
A: 

One word: suffering

Seth
Or how about, three words: indecipherable compiler errors
Charles Salvia
A: 

I found the word: type-independence. what do you think of that?

w4j3d