Content deleted Content added
Cleaned up references section to be consistent with other articles |
→Templates vs. generics: Added updated C++ info with concepts Tags: Mobile edit Mobile web edit |
||
Line 369:
| Wildcards supported as type parameter.
|-
|
| Supports bounding of type parameters with "extends" and "super" for upper and lower bounds, respectively; allows enforcement of relationships between type parameters.
|-
Line 381:
| Static variables shared between instances of classes of different type parameters.
|-
| Class and function templates do not necessarily enforce type relations for type parameters in their declaration. Use of an incorrect type parameter results in compiling failure, often generating an error message within the template code rather than in the user's code that invokes it. Proper use of templated classes and functions is dependent on proper documentation. Metaprogramming provides these features at the cost of added effort.
| Generic classes and functions can enforce type relationships for type parameters in their declaration. Use of an incorrect type parameter results in a type error within the code that uses it. Operations on parametrized types in generic code are only allowed in ways that can be guaranteed to be safe by the declaration. This results in greater type safety at the cost of flexibility.
|-
|