Generic programming: Difference between revisions

Content deleted Content added
WikiCleanerBot (talk | contribs)
m v2.05b - Bot T20 CW#61 - Fix errors for CW project (Reference before punctuation)
Line 245:
</syntaxhighlight>
 
Macros are expanded (copy pasted) by the [[preprocessor]], before compiling proper; templates are actual real functions. Macros are always expanded inline; templates can also be [[inline function]]s when the compiler deems it appropriate.
 
However, templates are generally considered an improvement over macros for these purposes. Templates are type-safe. Templates avoid some of the common errors found in code that makes heavy use of function-like macros, such as evaluating parameters with side effects twice. Perhaps most importantly, templates were designed to be applicable to much larger problems than macros.