Isn’t the template argument (the signature) of std::function part of its type?

The problem is that both function<int()> and function<int(int)> are constructible from the same function. This is what the constructor declaration of std::function looks like in VS2010: template<class _Fx> function(_Fx _Func, typename _Not_integral<!_Is_integral<_Fx>::value, int>::_Type = 0); Ignoring the SFINAE part, it is constructible from pretty much anything. std::/boost::function employ a technique called type erasure, to allow … Read more

std::function vs template

In general, if you are facing a design situation that gives you a choice, use templates. I stressed the word design because I think what you need to focus on is the distinction between the use cases of std::function and templates, which are pretty different. In general, the choice of templates is just an instance … Read more