It seems to me this is a compiler glitch. Using Clang compiler of Visual Studio 2017 only this error is generated “cannot refer to class template ‘foo’ without a template argument list” for a and b instantiation in main function. If the function type is specified as template parameter, there are no warnings and no errors.