This is just for fun and to see how people do it, it will help me to learn different techniques also.
If no one answers i will understand. :)
Lets say you have a template class. You want a certain method of this class will have some sort of checking mechanism before doing a operation.
Different types of object need different kinds of checking. User of this class know whether he needs to do the check or not. If he needs to do the check then he has to provide a function to this template which template class will call to do the check.
How do you make it generic? for better understanding, below code is to demonstrate what our goal is"
// This is only an example, you can change anything to make it work
template <class T>
class JustForFun{
myExecFun(){
if( /*CHECK THAT Function*/ ){
sampleExecute();
}
else{
cout << "condition doesnt match" << endl;
}
}
sampleExecute(){
//some operation
}
}