C.M.
C.M.

Reputation: 3383

lambda capture fails (on MSVC) if object has no copy constructor

Code to reproduce:

struct S
{
    S();
    S(S const&) = delete;
};

auto x = [s = S()]{};

It looks like MSVC doesn't apply (mandatory in C++17?) copy elision when building lambda. This breaks some of my code...

Does VC's behavior violate standard?

Upvotes: 4

Views: 192

Answers (1)

C.M.
C.M.

Reputation: 3383

Per "Language Lawyer"s comment: this is a known bug in MSVC that has been fixed in VS19 v16.2 and VS17 v15.8. Unfortunately (as of now) fix works only with /std:c++latest.

Upvotes: 2

Related Questions