[rescue] Mozilla Firefox

Peter Corlett abuse at cabal.org.uk
Fri Apr 23 10:05:32 CDT 2004

Joshua Boyd  <jdboyd at jdboyd.net> wrote:
> I actually like templates. I just wish they would allow a bit more
> overloading. Like, say I write a templated class. I would then like to be
> able to overload certain methods and say "Do it this way instead of
> following the template if the data type in floats". Instead, I end up
> writing it a template class, then rape and paste out any optimized
> versions I may need. Grr.

Erm, you don't *need* to use a class for template specializations:

// define a primary template
template<typename T> T max(const T &a, const T &b) {
  return (a<b) ? b : a;

// template specializations
template<> const char *max(const char *a, const char *b) {
  return (strcmp(a, b)>0) ? a : b;

template<> bool max(bool a, bool b) {
  return a || b;

When I'm good, I'm good. When I'm bad, I'm very good.
								- Mae West

More information about the rescue mailing list