Explicit Specializing VS. overloading

Hi, i have several functions( operator<<() ) wich must work with random types. But there is different realization for some of types. So i must use templates or overload functions. The question is which one is more effective?
overload in this case.

You don't want to write a generic template for operator<< (which would be required for specialization) since
the streams already provide operator<< for all of the built-in types.
Let me explain what i want to do. i don't use operator<< as stream operator. i create some class which will be fill buffer, and to copy files to buffer i want use operator<< except CopyMemory or memcpy function. And i want to know which will be more effective?
If the left-hand side is not derived from std::basic_ostream, then forget what I said above.

In that case, specialization sounds like a more maintainable approach.

When you specialize, it means you have a generic template that will handle mostly any type, except
for the few that you specialize.

When you overload, it means you write separate implementations for every type you want to support.
Topic archived. No new replies allowed.