Title
Should lambda to function pointer conversion function be noexcept?
Status
cd4
Section
7.5.6.2 [expr.prim.lambda.closure]
Submitter
Ville Voutilainen

Created on 2013-07-31.00:00:00 last changed 95 months ago

Messages

Date: 2015-10-15.00:00:00

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

Date: 2015-05-15.00:00:00

Proposed resolution (May, 2015):

Change 7.5.6 [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]).

Date: 2013-07-31.00:00:00

According to 7.5.6 [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.

History
Date User Action Args
2017-02-06 00:00:00adminsetstatus: dr -> cd4
2015-11-10 00:00:00adminsetmessages: + msg6068
2015-11-10 00:00:00adminsetstatus: ready -> dr
2015-05-25 00:00:00adminsetmessages: + msg5448
2015-05-25 00:00:00adminsetstatus: drafting -> ready
2013-10-14 00:00:00adminsetstatus: open -> drafting
2013-07-31 00:00:00admincreate