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 />
A More Reasonable Example<br />
Suppose we want to put new class we’ve made (MyClass)<br />
into an unordered map or unordered set<br />
We must define wh<strong>at</strong> it means to hash our new class<br />
#include <br />
namespace std {<br />
templ<strong>at</strong>e <br />
struct hash {<br />
size_t oper<strong>at</strong>or()( const MyClass & c ) const {<br />
size_t ret = /* do something awesome <strong>here</strong> */ ;<br />
// and probably <strong>here</strong><br />
return ret;<br />
}<br />
};<br />
}