1

Before C++17, the below code snippet appears to cause the compiler to complain, but it will work since C++17.

I am looking at cppreference page, in which I don't see any updates on it for C++17. But, instead, I only see that prvaule operand will return compiler to omit copy and move.

Can anyone point me to the C++ standards on this change?

atomic<int> atoc_1 = 1;

kyle
  • 691
  • 1
  • 7
  • 17
SSY
  • 627
  • 4
  • 10
  • 2
    I'm not sure I understand the point of your question. It works because that's what guaranteed copy elision says happens; it's nothing specific to `atomic`. Also, that page starts with a *gigantic* block of C++17-only text; how did you not "see any updates on it for C++17"? – Nicol Bolas Feb 16 '19 at 16:02
  • @NicolBolas what I mean is that I do see there are some updates for C++17 that copy elision will be guaranteed in some cases but I suppose the paragraph below to say that copy/move ctor is required should be pre-c++17 only. – SSY Feb 17 '19 at 14:10

1 Answers1

0

Here is the committee paper (P0135r1) that provided the precise diff between C++14 and C++17 to make this change. It's a fair amount of wording and is not easy reading.

Howard Hinnant
  • 206,506
  • 52
  • 449
  • 577