I find myself constantly writing 4 different functions for the same use case.
Let's say I want to write a function 'contains' which tells me if the given set/map contains a value. Here would be my implementation:
template <class T, class V> bool contains(T S, V val) {
return S.find(val) != S.end();
}
Now this function can be called by any template T. Can I restrict this to only apply to the above 4 stl classes? Or is there any other way to achieve my desired behaviour? I'm just making these functions for my own practice, so hacky solutions most welcome.