Why is this code trying to call the copy constructor?

后端 未结 2 1579
悲&欢浪女
悲&欢浪女 2020-11-27 07:36

I just spent an inordinate amount of time fiddling with a complilation error in Visual Studio. I have distilled the code into the small compilable example below and tried it

相关标签:
2条回答
  • 2020-11-27 08:12

    You must be facing a compiler bug. The standard says that B gets an implicitly declared and defined move constructor; all the conditions of 12.8(9) are met (i.e. B does not have an explicitly declared copy constructor, copy-assignment, etc, and the move constructor would not implicitly be declared deleted).

    0 讨论(0)
  • 2020-11-27 08:23

    If you are using Visual Studio 2010 or 2012, be advised: the compiler does not automatically generate move constructors for you. That wasn't implemented. So you need to write them yourself.

    0 讨论(0)
提交回复
热议问题