Title
Capturing an empty pack expansion
Status
nad
Section
7.5.6.3 [expr.prim.lambda.capture]
Submitter
Michael Wong

Created on 2013-04-15.00:00:00 last changed 136 months ago

Messages

Date: 2013-09-15.00:00:00

Rationale (September, 2013):

The statement in 7.5.6 [expr.prim.lambda] paragraph 6 is a syntactic constraint, not a semantic one. The example has a lambda-capture, regardless of its expansion in a given instantiation. This is consistent with the intent expressed in 13.7.4 [temp.variadic] paragraph 6:

When N is zero, the instantiation of the expansion produces an empty list. Such an instantiation does not alter the syntactic interpretation of the enclosing construct...
Date: 2022-11-20.07:54:16
N3690 comment CA 19

The conditions under which a closure class has a conversion function to a pointer-to-function type are given in 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...

Does this apply to a lambda whose lambda-capture is empty by virtue of being an empty pack expansion? For example, is the following well-formed?

  #include <cstdlib>

  template <typename ...Args>
  void foo(Args ...args) {
    auto xf = [args ...] { };
    std::atexit(xf);
  }

This is likely a violation of the rule in 13.8 [temp.res] paragraph 8,

If every valid specialization of a variadic template requires an empty template parameter pack, the template is ill-formed, no diagnostic required.

Does this need to be clarified?

History
Date User Action Args
2013-10-14 00:00:00adminsetmessages: + msg4704
2013-10-14 00:00:00adminsetstatus: open -> nad
2013-04-15 00:00:00admincreate