C++ template restrictions
- by pingvinus
I wondering is there any way to set restrictions on template class?
Specify that every type substituted in template must have specific ancestor (realize some interface).
template < class B > //and every B must be a child of abstract C
class A {
public:
B * obj;
int f() {
return B::x + this->obj->f();
}
};
Like = in haskell
func :: (Ord a, Show b) => a -> b -> c