▁any ▁compatible ▁parameter izing ▁types . ▁ ▁Template ▁special ization ▁A ▁powerful ▁feature ▁of ▁C ++ ' s ▁templates ▁is ▁template ▁special ization . ▁This ▁allows ▁alternative ▁implementations ▁to ▁be ▁provided ▁based ▁on ▁certain ▁characteristics ▁of ▁the ▁parameter ized ▁type ▁that ▁is ▁being ▁instanti ated . ▁Template ▁special ization ▁has ▁two ▁purposes : ▁to ▁allow ▁certain ▁forms ▁of ▁optimization , ▁and ▁to ▁reduce ▁code ▁b loat . ▁ ▁For ▁example , ▁consider ▁a ▁sort () ▁template ▁function . ▁One ▁of ▁the ▁primary ▁activities ▁that ▁such ▁a ▁function ▁does ▁is ▁to ▁swap ▁or ▁exchange ▁the ▁values ▁in ▁two ▁of ▁the ▁container ' s ▁positions . ▁If ▁the ▁values ▁are ▁large ▁( in ▁terms ▁of ▁the ▁number ▁of ▁bytes ▁it ▁takes ▁to ▁store ▁each ▁of ▁them ), ▁then ▁it ▁is ▁often ▁quick er ▁to ▁first ▁build ▁a ▁separate ▁list ▁of ▁pointers ▁to ▁the ▁objects , ▁sort ▁those ▁pointers , ▁and ▁then ▁build ▁the ▁final ▁sorted ▁sequence . ▁If ▁the ▁values ▁are ▁quite ▁small ▁however ▁it ▁is ▁usually ▁fast est ▁to ▁just ▁swap ▁the ▁values ▁in - place ▁as ▁needed . ▁Furthermore , ▁if ▁the ▁parameter ized ▁type ▁is ▁already ▁of ▁some ▁pointer - type , ▁then ▁there ▁is ▁no ▁need ▁to ▁build ▁a ▁separate ▁pointer ▁array . ▁Template ▁special ization ▁allows ▁the ▁template ▁cre ator ▁to ▁write ▁different ▁implementations ▁and ▁to ▁specify ▁the ▁characteristics ▁that ▁the ▁parameter ized ▁type ( s ) ▁must ▁have ▁for ▁each ▁implementation ▁to ▁be ▁used . ▁ ▁Un like ▁function ▁templates , ▁class ▁templates ▁can ▁be ▁partially ▁special ized .