Templates

Hi,
Is there a way where we can restrict the Templates to be used by only certain number of classes(apart from specialization). Because the we cannot guarantee, that all the class types we create in future will run currently on the code we wrote. Now the onus will fall on the User to understand the code and then use it, which breaks abstraction. Any comments?
Nope. The best solution as of now is to name your template type well, then put a comment describes what kinds of things it needs. You'll have to wait for concepts...whenever that gets in...:/
Because the we cannot guarantee, that all the class types we create in future will run currently on the code we wrote.

What firedraco said is correct, but since templates are duck typed - basically, the documentation of a template class will tell you what the template expects of it's type parameter(s) - namely operators and other methods, as well as their (abstract) behaviour. If your code runs only for two or three types then it's not really a generic problem, and in that case you should probably ask yourself if a template is really the best method to solve the problem.
Oh I see...... So its a design choice of templates. Got it. Thnx.
Topic archived. No new replies allowed.