I am thinking to write a function that works both for sequence and associative container. That's something like
template<class C, class V = typename C::key_type>
bool has_val(const C& c, const V& v)`
Inside the function, I would like to
- Check if class C has member function
const_iterator find(key_type) const
for container classes like set/map. - If it doesn't contain find(), then we use
std::find()
for sequence container likestd::vector
.
What's the best practice to check, (1)?
If what I described above is not the best, please advise if there's a better approach?
(Unfortunately I don't have access to newer Folly with macro FOLLY_create_member_invoker
but I do have FOLLY_CREATE_HAS_MEMBER_FN_TRAITS
. I couldn't successfully get it through, though)