I've got two functions defined:
std::vector<ptr> find(const ptr&, const std::function<bool(const ptr&)>&, const std::function<bool(const ptr&)>&);
and
std::vector<ptr> find(const ptr&, const std::function<bool(const ptr&)>&, const std::function<bool(const std::vector<ptr>&)>&);
I'm trying to rewrite them as template function accepting template arguments for the functions, in order to avoid new/delete for the std::function and avoiding calling via a virtual function.
template<typename CHECK, typename DIVE>std::vector<ptr> find(const ptr&, const CHECK&, const DIVE&);
But the compiler gets confused as the template definition for both functions is identical. Is there some way to do this -- e.g. by using some static_assert that the argument must be convertable to a std::function with a certain argument set?
I'm bound to C++11...
std::function<bool<const ptr&>&, ...looks wrong. Is that a typo?std::function<>will automatically involve dynamic allocation is incorrect.