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

Viewed 164

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?

1 Answers

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.

Related