Jump to content

Photo

Move Constructors and Assignment Operators

c++11

  • Please log in to reply
2 replies to this topic

#1 Mero

Mero

    Touch Fluffy Tail

  • Banned
  • Real Name:Tamamo No Mae
  • Location:Rainbow Factory

Posted 01 May 2013 - 11:50 AM

Are you required to have have copy constructors and assignment operators defined as well to make use of this new feature of c++11?

#2 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 02 May 2013 - 12:59 AM

I have found that if your class needs a non-default assignment, copy constructor, or destructor, then you probably need all three or else you're likely going to shoot yourself in the foot (un)expectedly.
Likewise, if you don't need any of these, then you should let the compiler generate the optimized defaults for them, since it will treat it POD.

#3 Koh

Koh

    Tamer Koh

  • Members
  • Real Name:Dominic
  • Location:Monsbaiya, Virginia

Posted 04 May 2013 - 10:23 AM

I have found that if your class needs a non-default assignment, copy constructor, or destructor, then you probably need all three or else you're likely going to shoot yourself in the foot (un)expectedly.
Likewise, if you don't need any of these, then you should let the compiler generate the optimized defaults for them, since it will treat it POD.

The Rule of the Big 3 in my programming class. If you ever need to define either, a Copy Constructor, Destructor, or Assignment, then you better define all three. What's this new C++11? *googles*



Also tagged with one or more of these keywords: c++11

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users