here - Chara - University of Illinois at Urbana-Champaign
here - Chara - University of Illinois at Urbana-Champaign
here - Chara - University of Illinois at Urbana-Champaign
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Lecture<br />
04—Templ<strong>at</strong>e<br />
P<strong>at</strong>terns I<br />
Chase Geigle<br />
Announcements<br />
Templ<strong>at</strong>e<br />
Specializ<strong>at</strong>ion<br />
Partial<br />
Templ<strong>at</strong>e<br />
Specializ<strong>at</strong>ion<br />
Templ<strong>at</strong>e<br />
Templ<strong>at</strong>e<br />
Parameters<br />
Next Time<br />
Motiv<strong>at</strong>ion<br />
Templ<strong>at</strong>e specializ<strong>at</strong>ion allows us to define custom<br />
behavior for a specific type<br />
...but wh<strong>at</strong> if we want to define custom behavior for a<br />
collection <strong>of</strong> types (e.g. pointers)?<br />
Example: Imagine we wanted vector to take<br />
ownership <strong>of</strong> the int * inserted?<br />
We want delete to be called on each item <strong>of</strong> the<br />
collection during destruction—this won’t happen with our<br />
ordinary definition.<br />
Adding a specializ<strong>at</strong>ion for every pointer type we use isn’t<br />
feasible