On 03/28/2013 10:54 AM, Bradley Lowekamp wrote:
> On Mar 28, 2013, at 10:33 AM, "Williams, Norman K" 
> <[email protected]> wrote:
>> 1. operator= returning void -- this seems like it's completely wrong, even
>> if the result is never used in practice.
>
> 1 ) I agree it seem wrong to me. If the method is returning void

The convention is used in places where we want to poison operator=
because it should not be called.  Typically the copy constructor
is also poisoned.  If this convention has leaked outside this use
case then those instances should be fixed.

> My personal favorite way to implement the assignment operator
> is using the copy constructor, followed by a swap.

Yes, this is *the* way to do it for exception safety.
The simplest way to do this is to arrange something like:

 X& operator=(X x) // by value so it is copy constructed!
   {
   swap(*this, x);
   return *this;
   }

-Brad
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.itk.org/mailman/listinfo/insight-developers

Reply via email to