Open2

C++ラムダ変遷

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}

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]

ログインするとコメントできます