← Back to team overview

kicad-developers team mailing list archive

Re: operator == on PCB_PLOT_PARAMS

 

The copy constructor and assignment operator are pretty basic to
polymorphism and C++ Inheritance, Equality is a different issue.

-----Original Message-----
From: kicad-developers-bounces+crash=triad.rr.com@xxxxxxxxxxxxxxxxxxx
[mailto:kicad-developers-bounces+crash=triad.rr.com@xxxxxxxxxxxxxxxxxxx] On
Behalf Of Cirilo Bernardo
Sent: Friday, August 03, 2012 6:55 PM
To: Lorenzo Marcantonio; Kicad Developers
Subject: Re: [Kicad-developers] operator == on PCB_PLOT_PARAMS





----- Original Message -----
> From: Lorenzo Marcantonio <l.marcantonio@xxxxxxxxxxxx>
> To: Kicad Developers <kicad-developers@xxxxxxxxxxxxxxxxxxx>
> Cc: 
> Sent: Friday, August 3, 2012 8:45 PM
> Subject: Re: [Kicad-developers] operator == on PCB_PLOT_PARAMS
> 
> On Fri, Aug 03, 2012 at 12:39:52PM +0200, Lorenzo Marcantonio wrote:
>>  Why is the operator definition needed? If the semantic is a 
>> field-by-field
> comparison, it should get a default, like for assigment (it doesn't, 
> tried
> it:P)
> 
> Oops found the answer... there is no default == operator in C++ :P:P 
> (strange, they got default = but not default ==)
> 
> --
> Lorenzo Marcantonio
> Logos Srl
> 

It's very simple; for an '=' operator you only need to copy a known amount
of memory to provide a default operator which is useful in almost 100% of
cases.  There is no such generalization possible for the equivalence
operator if a parameter is anything more than a single CPU register.  For
example, consider the quaternion represented by a structure containing 4
floats.  When you check for the equivalence of the quaternions you only need
to check 3 of those floats; if the quaternions are not normalized then you
cannot even directly compare the 3 values to determine if the quaternions
are equivalent.  In my experience this situation is extremely common so I am
not surprised that there is no default '==' operator.

- Cirilo

_______________________________________________
Mailing list: https://launchpad.net/~kicad-developers
Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
Unsubscribe : https://launchpad.net/~kicad-developers
More help   : https://help.launchpad.net/ListHelp



References