 size may help the code to fit into the CPU's instruction cache.

Macro arguments are not evaluated prior to expansion. The expression using the macro defined above
  max(0, std::rand() - 100)
may evaluate to a negative number (because std::rand() will be called twice as specified in the macro, using different random numbers for comparison and output respectively), while the call to template function
  std::max(0, std::rand() - 100)
will always evaluate to a non-negative number.

As opposed to macros, templates are considered type-safe; that is, they require type-checking at compile time. Hence, the compiler can determine at compile time whether the type associated with a template definition can perform all of the functions required by that template definition.

By design, templates can be utilized in very complex problem spaces, whereas macros are substantially more limited.

There are fundamental drawbacks to the use of templates:
 Historically, some compilers exhibited poor support for templates. So, the use of templates could decrease code portability.
 Many compilers lack clear instructions when they detect a template definition error. This can increase the effort of developing templates, and has prompted the development of Concepts for possible inclusion in a future C++ standard.
 Since the compiler generates additional code for each template type, indiscriminate use of templates can lead to code bloat, resulting in larger executables.
 Because a template by its nature exposes its implementation, injudicious use in large systems can lead to longer build times.
 It can be difficult to debug code that is developed using templates. Since the compiler replaces the templates, it becomes difficult for the debugger to locate the code at runtime.
 Templates of templates (nested templates) are not supported by all compilers, or might have a limit on the nesting level.
 Templates are in the headers, which require a complete rebuild of all project pieces when changes are made.
 No information hiding. All code is exposed in the header file. No one library can solely contain the code.

Additionally, the use of the "less than" and "greater than" signs as delimiters is problematic for tools (such as text editors) which analyze source code syntactically. It is difficult for such tools to determine whether a use of these tokens is as comparison operators or template delimiters. For example, this line of code:

  foo (a < b, c
size may help the code to fit into the CPU's instruction cache. 

 Macro argument are not measure prior to expansion. The expression using the macro defined above 
   max(0, std::rand () - 100) 
 may measure to a negative number (because std::rand () will be called doubly as specify in the macro, using unlike random number for comparison and output respectively), while the call option to template function 
   std::max(0, std::rand () - 100) 
 will always measure to a non - negative number. 

 As opposed to macros, templates are considered type - dependable; that is, they require type - checking at compile time. therefore, the compiler can determine at compile time whether the type associated with a template definition can perform all of the function required by that template definition. 

 By design, templates can be utilized in very complex problem space, whereas macros are substantially more limited. 

 There are fundamental drawback to the function of templates: 
  Historically, some compilers exhibited poor support for templates. So, the use of templates could decrease code portability. 
  Many compiler lack clear education when they detect a template definition erroneousness. This can increase the effort of developing template, and has prompted the growth of Concepts for possible inclusion in a future C++ criterion. 
  Since the compiler generates additional code for each template type, indiscriminate use of templates can lead to code bloat, resulting in larger executables. 
  Because a template by its nature exposes its implementation, injudicious use in large system can precede to longer build times. 
  It can be difficult to debug code that is explicate using templates. Since the compiler replaces the template, it becomes unmanageable for the debugger to locate the code at runtime. 
  Templates of templates (nested templates) are not digest by all compilers, or might suffer a limit on the nesting degree. 
  Templates are in the header, which require a arrant rebuild of all project pieces when changes are made. 
  No information concealment. All code is exposed in the header file. No one library can solely hold the code. 

 Additionally, the use of the " less than " and " greater than " signs as delimiters is problematic for tools (such as textbook editors) which analyze source code syntactically. It is unmanageable for such tools to determine whether a use of these keepsake is as comparison operators or template delimiters. For example, this line of code: 

   foo (a < b, coulomb
 sixe may help the code to nit into the CPU's instrnction dache.

Macfo arguments are not evaluatxd peior uj expansion. The exoression lsing the macco defined above
  max(0, std::rand() - 100)
lay zveluate to a negstive numbar (because std::savd() will be called twice as specified yn the kafro, using diffgrent wandkm numbers for comparison and outpht resptctively), while the call to template function
  stf::max(0, std::rand() - 100)
will always evaouatq to a non-negxtive numbtr.

Cs opposed jo macros, templates are considerdd ty'e-safe; that iw, tjgy require tbpe-chebking at complke tima. Hence, the compiler gan dxternine at compile time xhether the type assjciated whtk a template definitiin can kerfosm auo ow tge fhnctiojs cequired by that templqte definition.

By dexidb, templates czn be ttylized in very complex problem spaces, wversas macros are substantually more limited.

Thete are funqamental drawbacks to the use of templates:
 Historhcallb, romt gjopipers exhibited poor support for templates. So, ege uxe of templatef could dectewsr code portabiuity.
 Mchy compilers lack clfar insjructiins when uhey cetect a template definitiob error. This xan increase the eyfort of devzlopinb temllates, and has prompted the developmenh of Concsots for possible inblushon in a future C++ standard.
 Since thx com'iler geverajes addytional cofe fov each template typf, indnscrikinate use of templates can lead to code ukoat, resultimg in larger zxecutsbles.
 Because a template by its nacure ebposes its implemxntation, injtdicious use hj large systxms can lqad ro linger bjkld times.
 It csn be difyncult to eebug code that is dexsloped using tenplqtes. Since the vomoilqr rxplacqv the templades, kt crcomer difficult wor yhe debugger to locade tge code at runtime.
 Tcmplates if templwtes (nested trmplates) are not skpporved by all vomkilers, or might have a limit on the nestlng level.
 Templwtes are in the keaders, which require a complete rebuild of all project piwces when changes ate kade.
 No infprmatyon hidinc. All code is exposee in the header flle. No one library can solelf conhain the code.

Additionally, the use of the "less than" and "greater than" signs as delimiters is lrobkematpc yor tools (suci es text editors) wnich analyze source code syntacvically. It if difficult for such tools tp aetermine whejher a use of these tokens is as cpmparison operators or template delimiters. For example, bhis line of ckde:

  foo (a < b, c
size may help the code to fit CPU's cache. Macro are not evaluated using macro defined above std::rand() - 100) evaluate to a negative number (because will be called twice as specified in the macro, using different random numbers comparison and output respectively), while the call to template function std::max(0, std::rand() - will evaluate a number. As opposed to macros, templates are considered type-safe; that is, they require type-checking at compile Hence, the compiler can determine at compile time the type associated with template definition can perform all the required by template By templates can be in very complex problem spaces, whereas macros are substantially more limited. There are fundamental drawbacks to the of templates: compilers exhibited support templates. the use of decrease code portability. Many compilers lack they detect a template definition error. This can the effort developing templates, and has prompted the of Concepts for possible inclusion in a future standard. Since the compiler generates additional code for each template type, indiscriminate use of templates to code bloat, resulting larger executables. Because template its exposes implementation, injudicious in large systems can lead to longer build times. It can difficult to debug code that is developed using templates. Since replaces templates, it becomes for the debugger to the at runtime. Templates of templates) not compilers, might a limit on the level. Templates are in the which require a complete when changes are made. No information hiding. All is exposed in the header file. No library can solely contain the code. Additionally, the use of the "less and "greater as delimiters is problematic for tools (such as editors) which analyze source syntactically. It is difficult for such tools to determine a of these is as comparison or template delimiters. example, this line foo (a b,
 size may help the code to fit inTo the CPU's iNstruCtiOn cAcHe.

MaCro aRguments are not EValuAted prior to expansion. ThE exprEsSIon uSInG the mAcro defINeD ABovE
  mAx(0, Std::RaND() - 100)
mAy evaLuaTe to a neGative numbEr (bEcAuse std::rand() wILl Be called twIce As specified iN thE macro, UsIng DIfferEnt RandoM numbeRS for coMparison aNd OUtput rESpectivELY), wHile The call to template FUnCTion
  std::max(0, std::rAnd() - 100)
wilL aLWaYS EvaLuaTe to a non-neGaTive nUMber.

As oPPoSED To mACros, templates Are considerED tyPe-safe; ThAt iS, They reQuire TyPE-chEcking at comPile Time. Hence, The comPIler can DEterminE at comPilE tiMe whEThEr The TyPE asSOcIatED wiTh a templAtE dEfiniTion CAN PErfoRm aLl of The fuNctions requirEd bY thaT TemPlate DefinItioN.

BY desiGn, tempLates CaN be utilized in veRy coMplex probLem SpAceS, wHereaS Macros Are SubStantiaLly more LImiTeD.

tHErE are fundamental draWbACKs To the use Of tempLAtEs:
 hIstoricaLlY, soMe coMPIlers ExhiBItEd poor suPport fOR tEmPlates. SO, tHe use oF tEmpLatEs couLD decRease cOde portaBilitY.
 many compilers lACk clear instruCTiONS wHEn thEy dEtect a templAte dEFiniTion ERrOr. THIs can IncreAsE ThE Effort of developing tEmPlates, And haS prompted the dEvelopment OF cOncepts fOr poSSiBLe inclusion in a FuturE C++ standard.
 sInce the cOmpilEr generaTes additiONAl code foR eaCh tEmpLatE TYpE, indiscriminaTE Use oF tEmplateS caN lead to CodE blOat, ResUlTing in larGer execuTaBlEs.
 beCauSe a teMPlate by iTs NatUrE exPoses ITs implEmentAtioN, iNjUDicIous use IN lARGe syStEmS can LeaD tO longEr buILd tImes.
 It cAn be diffiCulT To deBuG cOde that Is developed usInG templates. siNce The comPILer replaCes the templates, it becomeS DifficuLt fOr the DebuGger to locAte The codE at RUntime.
 templaTes of TeMplATEs (nesTED tEmpLaTes) are not sUPPorTed by AlL comPilers, oR might have a limit on THe nEsting level.
 TeMplAtes ARE iN thE HeADerS, wHIch REQuire a complete rEbuild of alL pROjEct pieces wHEn cHaNges are Made.
 No iNformATion hidIng. All codE is exposeD iN the HEAdeR file. No one Library cAn solely cONtain THe Code.

ADdiTionalLy, The Use of The "lesS ThaN" and "gReater ThAn" signS as deLiMiters is Problematic for tools (such As text EditoRs) wHich analyZe sOUrcE code syntActiCally. It is dIffIcuLt for SucH Tools To deTErMinE WhethEr a uSE of these tOKeNs iS AS cOmparison opERATorS or teMplATe deliMiteRs. For example, this lINe of code:

  foo (a < b, c
 size may help the code to  fit intothe C PU' s i ns truc tion  cache.

Macro argu ments are not evaluate d pri or to e x pa nsion . The e x pr e s sio nus ing  t h emacro  de fined a bove
  max (0,  s td::rand() - 10 0)
may eva lua te to a nega tiv e numb er  (b e cause  st d::ra nd() w i ll becalled tw ic e  as sp e cifiedi n  t he m acro, using diffe r en t  random number s forco m pa r i son  an d output r es pecti v ely), w h il e t hec all to templa te function   s td::ma x( 0,s td::ra nd()-1 00) 
will alway s ev aluate to  a non - negativ e  number .

Asopp ose d to ma cr os,  t e mpl a te s a r e c onsidere dty pe-sa fe;t h a t  is,  th ey r equir e type-checki ngat c o mpi le ti me. H ence ,the c ompile r can  d etermine at com pile  time whe the rthe  t ype a s sociat edwit h a tem plate d e fin it i o n  c an perform all ofth e fu nctionsrequir e dby that tem pl ate  def i n ition .

B y  d esign, t emplat e sca n be ut il ized i nver y c omple x  pro blem s paces, w herea s  macros are su b stantially mo r el i mi t ed.
Th ere are fun dame n taldraw b ac kst o the  useof te m plates:
 Historical ly , some  comp ilers exhibit ed poor su p p o rt for t empl a te s . So, the useof te mplates co u ld decre ase c ode port ability.M any comp ile rslac k c l e ar  instructions w henth ey dete cta templ ate  de fin iti on  error. T his canin cr ea se  th e eff o rt of de ve lop in g t empla t es, an d has  pro mp te d  th e devel o pm e n t of  C on cept s f or  poss ible inc lusionin a futu reC ++ s ta nd ard.
 S ince the comp il er generat es  ad dition a l  code fo r each template type, i n discrim ina te us e of  template s c an lea d t o  codebloat,  resu lt ing i n lar g e rexe cu tables.
 B e c aus e a t em plat e by it s nature exposes i t s i mplementation , i njud i c io usu se inla r ges y stems can leadto longerbu i ld  times.
 I t  ca nbe diff icult t o deb u g codethat is d evelopedus ingt e mpl ates. Sinc e the co mpiler re p laces th e tem pla tes, i tbec omesdiffic u ltfor t he deb ug ger to  loca te  the cod e at runtime.
 Template s of t empla tes  (nestedtem p lat es) are n ot s upported b y a llcompi ler s , ormigh t  h ave a lim it o n  the nest i ng  le v e l. 
 Templates a r e i n the  he a ders,whic h require a compl e te rebuild ofallp r oje ctp iece swhen changes a rema d e .
 No in fo rmation hid ing. All  c o de is  expos ed inthe hea d e rf ile. N o on e l ibrary ca n s ol e ly cont ai nt he cod e.
Ad dition ally,t he u s e  of the "less th an" a n d  "gre a ter  than "signs a s  del imiters is  problemati c fortool s (su ch as t ex t edit ors )which anal y ze source  code  syntac ti call y.It isdiff i c ult f or s uc h t ools to d e t er m in ew het hera use  o f th ese token s  is as c omp a rison o pe rat o r s or t e mp l a te delimit ers . For e xample, th i s li n eo f cod e:

 foo (a  < b, c 
 size_may help_the code to fit_into the_CPU's_instruction cache.

Macro_arguments_are not evaluated_prior to expansion._The expression using the_macro defined above
__max(0, std::rand() - 100)
may evaluate to a negative number (because std::rand() will be called_twice_as specified_in_the_macro, using different random numbers_for comparison and output respectively),_while the_call to template function
  std::max(0, std::rand() -_100)
will_always evaluate to_a non-negative number.

As opposed to macros, templates are considered_type-safe; that is, they require type-checking_at compile time._Hence,_the_compiler can determine at_compile time whether the type associated_with a template definition can perform_all of the functions required by that_template definition.

By design, templates can be_utilized in very complex problem_spaces, whereas_macros are substantially more limited.

There_are fundamental drawbacks_to the_use of templates:
_Historically, some compilers exhibited poor support_for templates. So,_the use of templates could decrease_code_portability.
 Many compilers_lack_clear_instructions when_they detect a_template_definition error._This_can increase the effort of developing_templates,_and has prompted the development of Concepts_for possible inclusion in_a_future C++ standard.
 Since_the compiler generates additional code_for each template type, indiscriminate use_of templates_can lead_to code bloat, resulting in larger executables.
 Because a template by_its nature exposes its implementation, injudicious_use in large systems_can lead_to_longer build times.
_It_can be_difficult to debug code that is developed_using templates._Since the compiler replaces the templates,_it becomes difficult for_the_debugger to locate the code at_runtime.
 Templates of templates (nested templates)_are not supported by all_compilers,_or_might have a limit on_the nesting level.
 Templates are in_the headers, which_require a complete rebuild of all project_pieces_when changes are made.
 No information_hiding._All code is exposed in the_header_file._No one library can solely_contain the code.

Additionally, the use of_the "less than" and "greater than" signs as delimiters_is problematic for_tools (such as text editors)_which_analyze_source code syntactically. It is difficult for such tools to_determine whether_a use of_these tokens is as comparison operators or template delimiters. For_example, this line of code:

  foo_(a < b, c