When using function as template parameter, along with template overload with different function signatures, VC++ is unable to resolve the function template parameter correctly. The following piece of code illustrates the issue:#include <cmath>#include <complex>#include <iostream>template <class T>class A{public: A (T t) : _t (t) { } A (const A& a) : _t (a._t) { } A& operator= (const A& a) { _t = a._t; return *this; } T val (void) const { return _t; }private: T _t;};template <class R, class T, R fun (T)>inline A<R> mapper (const A<T>& a){ return A<R> (fun (a.val ()));}template <class R, class T, R fun (const T&)>inline A<R> mapper (const A<T>& a){ return A<R> (fun (a.val ()));}int main (int argc, char **argv){ A<double> d (-1); A< std::complex<double> > c (std::complex<double> (1, 1)); std::cout << d.val () << " -> " << mapper<double, double, std::abs> (d).val () << std::endl; std::cout << c.val () << " -> " << mapper<double, std::complex<double>, std::abs> (c).val () << std::endl; return 0;}
Visual Studio/Team Foundation Server/.NET Framework Tooling version
Steps to reproduce
Product Language
Operating System
Operating System Language
Actual results
Expected results