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

2024-12-19


754. Lambda expressions in default arguments of block-scope function declarations

Section: 7.5.6  [expr.prim.lambda]     Status: CD2     Submitter: Daveed Vandevoorde     Date: 10 December, 2008

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

Is a lambda expression permitted in a default argument expression for a block-scope function declaration? For example,

    void g() {
      void f(std::reference_closure<void()> rc = []() {});
      f();
    }

This was not discussed in either the Evolution Working Group nor in the Core Working Group, and it is possible that some of the same implementation difficulties that led to prohibiting use of automatic variables in such default argument expressions (9.3.4.7 [dcl.fct.default] paragraph 7) might also apply to closure objects, even though they are not automatic variables.

(See also issue 772.)

Proposed resolution (July, 2009)

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