2

The cppreference says that

When the initializer is a prvalue, the move constructor call is often optimized out (until C++17) / never made (since C++17).

I have two questions:

1) Does this mean that construction with literals (e.g. integer 10) will never move construct?

2) What's the reasoning for this rule?

B M
  • 3,893
  • 3
  • 33
  • 47
  • 4
    That quote you quoted continues with `, see copy elision.` – DeiDei Dec 25 '18 at 19:24
  • My first question might be partially covered by `copy elision`, but the second one is not. – B M Dec 25 '18 at 22:23
  • 1
    @BM: The reasoning is "copy elision is good". Do you need another reasoning? Why would you *want* to waste runtime performance copying something that doesn't need to be copied? – Nicol Bolas Dec 25 '18 at 22:56

0 Answers0