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


775. Capturing references to functions

Section: 7.5.6.3  [expr.prim.lambda.capture]     Status: CD2     Submitter: Steve Adamczyk     Date: 12 February, 2009

[Voted into the WP at the July, 2009 meeting as part of N2927.]

According to 7.5.6 [expr.prim.lambda] paragraph 8, the “object type” of a captured function is the type to which the reference refers. That's clearly wrong when the captured reference is a reference to a function, because the resulting data member of the closure class will have a function type:

    void f() { }
    void g() {
      void (&fr)() = f;
      [fr]{};   // Oops...
    }

Proposed resolution (July, 2009)

See document PL22.16/09-0117 = WG21 N2927.