Title
Surrogate call template
Status
open
Section
12.2.2.2.3 [over.call.object]
Submitter
Jason Merrill

Created on 2015-10-22.00:00:00 last changed 111 months ago

Messages

Date: 2022-02-18.07:47:23

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.
History
Date User Action Args
2015-10-22 00:00:00admincreate