What is considered "good practice" in handling unwanted data types for templated classes?
Let's say we have a function in a templated class that does number multiplication, but the driver file for the class declares an instance of the class with Type string
.
I've been given the argument that this is a "personal problem" for whoever's creating the driver file, and that all that needs to be done on your part is proper function prologues in the header/implementation files.
I'm wondering if there is a general practice used with templates regarding this issue. Do you check your Types in a class before handling them (I guess, to a certain extent that defeats the purpose of a template), or do you define behavior for specific types (though this also seems like a defeat of purpose)?
Or do you simply document your code correctly and let the programmer who uses your class take the precautions?