This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115e. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-11-11


2189. Surrogate call template

Section: 12.2.2.2.3  [over.call.object]     Status: open     Submitter: Jason Merrill     Date: 2015-10-22

Consider:

  template <class T>
  using Fn = void (*)(T);

  struct A
  {
    template <class T>
    operator Fn<T>();
  };

  int main()
  {
    A()(42);
  }
12.2.2.2.3 [over.call.object] describes how conversion functions to pointer/reference to function work in overload resolution, but is silent about conversion function templates. Generalizing the wording there, in this case we could generate a surrogate conversion template
template <class T>
  void /surrogate/ (Fn<T> f, T a) { return f(a); }
which would work as expected. But it seems that implementations don't actually do this currently.