This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 110b. See for the official list.


300. References to functions in template argument deduction

Section:  [temp.deduct.type]     Status: CD1     Submitter: Andrei Iltchenko     Date: 11 Jul 2001

[Moved to DR at October 2002 meeting.]

Paragraph 9 of [temp.deduct.type] enumerates the forms that the types P and A need to have in order for template argument deduction to succeed.

For P denoting a pointer to function the paragraph lists the following forms as allowing for template argument deduction:


On the other hand, no provision has been made to accommodate similar cases for references to functions, which in light of the wording of [temp.deduct.type] paragraph 11 means that the program below is ill-formed (some of the C++ compilers do not reject it however):

    template<typename Arg, typename Result, typename T>
    Result  foo_r(Result(& rf)(Arg), T x)
    {   return  rf(Arg(x));   }

    template<typename Arg, typename Result, typename T>
    Result  foo_p(Result(* pf)(Arg), T x)
    {   return  pf(Arg(x));   }

    #include <iostream>
    int  show_arg(char c)
       std::cout << c << ' ';
       if(std::cout)  return  0;
       return  -1;

    int  main()
                                                   // The deduction
       int  (& rf1)(int(&)(char), double) = foo_r; // shall fail here
                                                   // While here
       int  (& rf2)(int(*)(char), double) = foo_p; // it shall succeed
       return  rf2(show_arg, 2);

Proposed resolution (10/01, same as suggested resolution):

In the list of allowable forms for the types P and A in paragraph 9 of [temp.deduct.type] replace