Topic: How different can be template class specia
Author: clamage@Eng.sun.com (Steve Clamage)
Date: 1998/02/24 Raw View
In article F1D6874D@typhoon.spb.ru, "Alexey N. Solofnenko" <trelony@typhoon.spb.ru> writes:
>
> It looks like you can write in template class specialization whatever
>you want. It would make a lot troubles to compiler (and programmer).
>Is it true?
It is true that a specialization can be quite different from the
original template. It doesn't cause any additional complications
for the compiler. If you abuse the language feature it might
confuse clients of the template, but that's true of many
language features.
For example, you could write overloaded functions that did unrelated
things, or an overloaded operator+ that subtracts two values.
Those are legal but ill-advised programming practices.
Similarly, template specializations can differ from the template
if it makes sense, but should not be wildly different
without a reason that will be obvious to users of the class.
---
Steve Clamage, stephen.clamage@sun.com
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]