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

2022-07-16


1722. Should lambda to function pointer conversion function be noexcept?

Section: 7.5.5.2  [expr.prim.lambda.closure]     Status: CD4     Submitter: Ville Voutilainen     Date: 2013-07-31

[Moved to DR at the October, 2015 meeting.]

According to 7.5.5 [expr.prim.lambda] paragraph 6,

The closure type for a non-generic lambda-expression with no lambda-capture has a public non-virtual non-explicit const conversion function to pointer to function with C++ language linkage (9.11 [dcl.link]) having the same parameter and return types as the closure type's function call operator.

This does not specify whether the conversion function is noexcept(true) or noexcept(false). It might be helpful to nail that down.

Proposed resolution (May, 2015):

Change 7.5.5 [expr.prim.lambda] paragraph 6 as follows:

The closure type for a non-generic lambda-expression with no lambda-capture has a public non-virtual non-explicit const conversion function to pointer to function with C++ language linkage (9.11 [dcl.link]) having the same parameter and return types as the closure type's function call operator. The value returned by this conversion function shall be the address of a function that, when invoked, has the same effect as invoking the closure type's function call operator. For a generic lambda with no lambda-capture, the closure type has a public non-virtual non-explicit const conversion function template to pointer to function. The conversion function template... [Example:

  auto GL = [](auto a) { std::cout << a; return a; };
  int (*GL_int)(int) = GL; // OK: through conversion function template
  GL_int(3);               // OK: same as GL(3)

end example] The conversion function or conversion function template is public, non-virtual, non-explicit, const, and has a non-throwing exception specification (14.5 [except.spec]).