Topic: Implicitly defined operator== and operator!=
Author: NDos Dannyu <ndospark320@naver.com>
Date: Sat, 25 Apr 2015 16:18:57 -0700 (PDT)
Raw View
------=_Part_18_740925866.1430003937223
Content-Type: multipart/alternative;
boundary="----=_Part_19_1506597249.1430003937230"
------=_Part_19_1506597249.1430003937230
Content-Type: text/plain; charset=UTF-8
Hi, everyone.
I'd like to submit a proposal.
My coding style involves many value classes, so I'd like to have implicitly
defined operator== and operator!=.
The reason is simple. For a value class that has very many members, it will
be a annoyance to define operator== and operator!= manually.
For Example:
struct ValueClass {
int fooi;
char fooc;
std::string foos;
// And many other members
};
As you see, this is a value class.
The operator== and operator!= would be like this:
bool ValueClass::operator == (const ValueClass &other) const {
return (fooi == other.fooi) && (fooc == other.fooc) && (foos ==
other.foos) /* && (for any non-static members) */;
}
bool ValueClass::operator != (const ValueClass &other) const {
return !(*this == other);
}
I want these to be implicitly defined.
These would not be implicitly defined if:
- operator== is explicitly defined, is pure-abstract, or is deleted
- operator== from any parent class is unaccessible, is pure-abstract, or
is deleted
- any member has operator== which is unaccessible, is pure-abstract, or
is deleted
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_19_1506597249.1430003937230
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>Hi, everyone.</div><div>I'd like to submit a proposal=
..</div><div>My coding style involves many value classes, so I'd like to hav=
e implicitly defined operator=3D=3D and operator!=3D.</div><div>The reason =
is simple. For a value class that has very many members, it will be a annoy=
ance to define operator=3D=3D and operator!=3D manually.</div><div>For Exam=
ple:</div><div dir=3D"ltr"> struct ValueClass {</div=
><div> int fooi;</div><div> =
char fooc;</div><div>  =
; std::string foos;</div><div> &nb=
sp; // And many other members</div><div>  =
; };</div><div>As you see, this is a value class.</div><div>The operat=
or=3D=3D and operator!=3D would be like this:</div><div> =
bool ValueClass::operator =3D=3D (const ValueClass &other) const {</div=
><div> return (fooi =3D=3D other.=
fooi) && (fooc =3D=3D other.fooc) && (foos =3D=3D other.foo=
s) /* && (for any non-static members) */;</div><div> &nb=
sp; }</div><div> bool ValueClass::operator !=3D (const Va=
lueClass &other) const {</div><div> =
return !(*this =3D=3D other);</div><div> }</d=
iv><div>I want these to be implicitly defined.</div><div><br></div><di=
v>These would not be implicitly defined if:</div><ul><li>operator=3D=3D is =
explicitly defined, is pure-abstract, or is deleted</li><li>operator=3D=3D =
from any parent class is unaccessible, is pure-abstract, or is deleted</li>=
<li>any member has operator=3D=3D which is unaccessible, is pure-abstract, =
or is deleted</li></ul><p><br></p></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_19_1506597249.1430003937230--
------=_Part_18_740925866.1430003937223--
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Sun, 26 Apr 2015 02:29:38 +0300
Raw View
On 26 April 2015 at 02:18, NDos Dannyu <ndospark320@naver.com> wrote:
> Hi, everyone.
> I'd like to submit a proposal.
> My coding style involves many value classes, so I'd like to have implicitly
> defined operator== and operator!=.
See
http://open-std.org/JTC1/SC22/WG21/docs/papers/2015/n4475.pdf
and
http://open-std.org/JTC1/SC22/WG21/docs/papers/2015/n4476.pdf
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
.