I have a functor which operates on a container of type U
of elements of type T
like so
template<typename T, template<typename...> class U>
class asserter
{
public:
asserter(U<T> &c) : container(c) { };
void operator()(T lhs)
{
CU_ASSERT(container.find(lhs) != container.end());
};
private:
U<T> &container;
};
which I might use as
std::set<std::string> a, c;
...
asserter<std::string, std::set> ass(c);
for_each(a.begin(), a.end(), ass);
Where we are ignoring std::includes()
for the moment.
This works great if the container is one where U::find()
is defined. If it's not I'd like to fall back to std::find()
. On the other hand I'd rather use U::find()
over std::find()
if it's available.
In C++11 (or 17 if necessary) can I determine if U::find()
is available (possibly restricting to the STL) for U and if so use it, otherwise use std::find()
?