Open3

C++ラムダ変遷

yohhoyyohhoy

C++11

C++11 [expr.prim.lambda]

lambda-expression:
    lambda-introducer lambda-declarator{opt} compound-statement
lambda-introducer:
    [ lambda-capture{opt} ]
lambda-capture:
    capture-default
    capture-list
    capture-default , capture-list
capture-default:
    &
    =
capture-list:
    capture ...{opt}
    capture-list , capture ...{opt}
capture:
    identifier
    & identifier
    this
lambda-declarator:
    ( parameter-declaration-clause ) mutable{opt}
    exception-specification{opt} attribute-specifier-seq{opt} trailing-return-type{opt}

Default arguments shall not be specified in the parameter-declaration-clause of a lambda-declarator.

C++14

C++14 [expr.prim.lambda]

lambda-expression:
    lambda-introducer lambda-declarator{opt} compound-statement
lambda-introducer:
    [ lambda-capture{opt} ]
lambda-capture:
    capture-default
    capture-list
    capture-default , capture-list
capture-default:
    &
    =
capture-list:
    capture ...{opt}
    capture-list , capture ...{opt}
capture:
    simple-capture
    init-capture
simple-capture:
    identifier
    & identifier
    this
init-capture:
    identifier initializer
    & identifier initializer
lambda-declarator:
    ( parameter-declaration-clause ) mutable{opt}
    exception-specification{opt} attribute-specifier-seq{opt} trailing-return-type{opt}

C++17

C++17 [expr.prim.lambda]

lambda-expression:
	lambda-introducer lambda-declarator{opt} compound-statement
lambda-introducer:
	[ lambda-capture{opt} ]
lambda-declarator:
	( parameter-declaration-clause ) decl-specifier-seq{opt}
	noexcept-specifier{opt} attribute-specifier-seq{opt} trailing-return-type{opt}

In the decl-specifier-seq of the lambda-declarator, each decl-specifier shall either be mutable or constexpr.

C++17 [expr.prim.lambda.capture]

lambda-capture:
	capture-default
	capture-list
	capture-default , capture-list
capture-default:
	&
	=
capture-list:
	capture ...{opt}
	capture-list , capture ...{opt}
capture:
	simple-capture
	init-capture
simple-capture:
	identifier
	& identifier
	this
	* this
init-capture:
	identifier initializer
	& identifier initializer

C++20

C++20 [expr.prim.lambda]

lambda-expression:
	lambda-introducer lambda-declarator{opt} compound-statement
	lambda-introducer < template-parameter-list > requires-clause{opt} lambda-declarator{opt} compound-statement
lambda-introducer:
	[ lambda-capture{opt} ]
lambda-declarator:
	( parameter-declaration-clause ) decl-specifier-seq{opt}
		noexcept-specifier{opt} attribute-specifier-seq{opt} trailing-return-type{opt} requires-clause{opt}

In the decl-specifier-seq of the lambda-declarator, each decl-specifier shall be one of mutable, constexpr, or consteval.

C++20 [expr.prim.lambda.capture]

lambda-capture:
	capture-default
	capture-list
	capture-default , capture-list
capture-default:
	&
	=
capture-list:
	capture
	capture-list , capture
capture:
	simple-capture
	init-capture
simple-capture:
	identifier ...{opt}
	& identifier ...{opt}
	this
	* this
init-capture:
	...{opt} identifier initializer
	& ...{opt} identifier initializer

If a lambda-capture includes a capture-default that is &, no identifier in a simple-capture of that lambda-capture shall be preceded by &. If a lambda-capture includes a capture-default that is =, each simple-capture of that lambda-capture shall be of the form "& identifier ...{opt}", "this", or "* this". [Note: The form [&,this] is redundant but accepted for compatibility with ISO C++ 2014. -- end note]

yohhoyyohhoy

C++23

WD [expr.prim.lambda]

lambda-expression:
	lambda-introducer attribute-specifier-seq{opt} lambda-declarator compound-statement
	lambda-introducer < template-parameter-list > requires-clause{opt} attribute-specifier-seq{opt}
		lambda-declarator compound-statement
lambda-introducer:
	[ lambda-capture{opt} ]
lambda-declarator:
	lambda-specifier-seq noexcept-specifier{opt} attribute-specifier-seq{opt} trailing-return-type{opt}
	noexcept-specifier attribute-specifier-seq{opt} trailing-return-type{opt}
	trailing-return-type{opt}
	( parameter-declaration-clause ) lambda-specifier-seq{opt} noexcept-specifier{opt} attribute-specifier-seq{opt}
		trailing-return-type{opt} requires-clause{opt}
lambda-specifier:
	consteval
	constexpr
	mutable
	static
lambda-specifier-seq:
	lambda-specifier
	lambda-specifier lambda-specifier-seq

A lambda-specifier-seq shall contain at most one of each lambda-specifier and shall not contain both constexpr and consteval. If the lambda-declarator contains an explicit object parameter ([dcl.fct]), then no lambda-specifier in the lambda-specifier-seq shall be mutable or static. The lambda-specifier-seq shall not contain both mutable and static. If the lambda-specifier-seq contains static, there shall be no lambda-capture.