Question Details

No question body available.

Tags

c++ lambda language-lawyer

Answers (1)

January 29, 2026 Score: 2 Rep: 48,694 Quality: Low Completeness: 70%

The program is ill-formed and msvc is wrong to accept it because any construct designating the deleted function (except to declare/define or reflect it) is ill-formed as per dcl.fct.def.delete:

A construct that designates a deleted function implicitly or explicitly, other than to declare it or to appear as the operand of a reflect-expression ([expr.reflect]), is ill-formed.

And since the use of C(3) in [b = C(3)] is neither declaring the deleted ctor nor an operand of a reflect-expression, the program is ill-formed.


Also, the declaration of var2 is accepted by all compilers because [C(3)] is an int capture and is actually equivalent to writing [C=3].