The lambda expression constructs an unnamed temporary object of unique unnamed non-union non-aggregate type, known as closure type, which has the following members:

The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions.

ClosureType ::

Original:

ClosureType::

The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions.

operator()

ret operator()(params)const{ body }

(a palavra-chave mutável não foi utilizado)

ret operator()(params){ body }

(a palavra-chave foi usada mutável)

Executes the body of the lambda-expression, when invoked. When accessing a variable, accesses its captured copy (for the entities captured by copy), or the original object (for the entities captured by reference). Unless the keyword mutable was used in the lamda-expression, the objects that were captured by copy are non-modifiable from inside this operator().

Dangling references

If an entity is captured by reference, implicitly or explicitly, and the function call operator of the closure object is invoked after the entity's lifetime has ended, undefined behavior occurs. The C++ closures do not extend the lifetimes of the captured references.

ClosureType ::

Original:

ClosureType::

The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions.

operator ret(*)(params)

typedef ret(*F)(params);
operator F()const;

This member function is only defined if the capture list of the lambda-expression is empty.

The value returned by this conversion function is a function pointer that, when invoked, has the same effect as invoking the closure object's function call operator directly.

ClosureType ::

Original:

ClosureType::

The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions.

ClosureType()

ClosureType()= delete;

ClosureType(const ClosureType&)=default;

ClosureType(ClosureType&&)=default;

Closure types are not DefaultConstructible. The copy constructor and the move constructor are implicitly-declared and may be implicitly-defined according to the usual rules for implicit copiar construtores and mover construtores.

ClosureType ::

Original:

ClosureType::

The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions.

operator=()

ClosureType& operator=(const ClosureType&)= delete;

Closure types are not CopyAssignable.

ClosureType ::

Original:

ClosureType::

The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions.

~ClosureType()

~ClosureType()=default;

The destructor is implicitly-declared.

ClosureType ::

Original:

ClosureType::

The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions.

CapturedParam

T1 a;

T2 b;

...

If the lambda-expression captures anything by copy (either implicitly with capture clause [=] or explicitly with a capture that does not include the character &, e.g. [a, b, c]), the closure type includes unnamed non-static data members, declared in unspecified order, that hold copies of all entities that were so captured.

The type of each data member is the type of the corresponding captured entity, except if the entity has reference type (in that case, references to functions are captured as-is, and references to objects are captured as copies of the referenced objects).

For the entities that are captured by reference (with the default capture [&] or when using the character &, e.g. [&a, &b, &c]), it is unspecified if additional data members are declared in the closure type.