Topic: Defect Report: 13.5.3 is unclear
Author: "Anthony Williams" <anthwil@nortelnetworks.com>
Date: 13 Aug 2002 15:11:04 GMT Raw View
[ moderator's note: Forwarded to C++ Committee. -sdc ]
It is unclear whether 13.5.3 Assignment [over.ass] implies that assignment
operators of the form op= are required to be members or not.
5.17 Assignment Operators [expr.ass], which defines the assignment operators
uses "Assignment Operator" to include the op= forms, and uses "simple
assignment operator" and "copy assignment operator" to refer to the plain =
form.
Therefore the use of the term "assignment operator" in 13.5.3 would imply that
it covers _all_ the assignment operators, including the op= form, and the
plain = form, thus requiring that they are all members.
However, since only plain = is given in the example, it is not clear that this
is the case; an alternative reading would be that this use of "assignment
operator" refers only to plain =, and thus allowing assignment operators of
the op= form to be implemented as non-members. This is the interpretation
taken by many compilers, including MetroWerks, EDG and g++.
Suggested resolution:
1. Change the use of "assignment operator" in 13.5.3 to "simple assignment
operator (=)", to make it clear that only the plain = form is required to
be implemented as a member function.
OR
2. Add a additional sentence or example to indicate that the op= forms are
also required to be implemented as member functions. e.g. change the first
sentence of 13.5.3p1 from "An assignment operator ..." to "All the
assignment operators (5.17) ...".
Anthony
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: jpotter@falcon.lhup.edu (John Potter)
Date: Wed, 14 Aug 2002 04:44:28 GMT Raw View
On 13 Aug 2002 15:11:04 GMT, "Anthony Williams"
<anthwil@nortelnetworks.com> wrote:
> It is unclear whether 13.5.3 Assignment [over.ass] implies that assignment
> operators of the form op= are required to be members or not.
>
> 5.17 Assignment Operators [expr.ass], which defines the assignment operators
> uses "Assignment Operator" to include the op= forms,
Ok.
> and uses "simple assignment operator"
The word operator does not appear in my copy of the standard. In /2
to refer to the semantics for fundamental types only. It has no
meaning for a UDT.
> and "copy assignment operator"
incorrectly in /4 to cover assignment to UDT. If that were true, then
what would T::operator= (int) do to a T? That is not a copy
assignment operator. It is an operator= which is an assignment
operator.
> 1. Change the use of "assignment operator" in 13.5.3 to "simple assignment
> operator (=)", to make it clear that only the plain = form is required to
> be implemented as a member function.
Since simple assignment was used without operator and did not apply to
this case anyway, it might be clearer to just say what C++PL/2e said,
"operator=". I know of no better way to say "operator=" than to just
say it. OTOH, if the intent is only copy assignment operator, then
say that.
John
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: "Anthony Williams" <anthwil@nortelnetworks.com>
Date: Wed, 14 Aug 2002 10:04:14 CST Raw View
jsa@edg.com (J. Stephen Adamczyk) writes:
> In article <8z3bjeu5.fsf@nortelnetworks.com> "Anthony Williams"
> <anthwil@nortelnetworks.com> writes:
> >It is unclear whether 13.5.3 Assignment [over.ass] implies that assignment
> >operators of the form op= are required to be members or not.
>
> This is resolved by core issue 221.
Thanks. I should have checked first.
However, I don't understand the comment about "if it did apply to compound
assignment operators [i.e. they had to be members] it would be impossible to
overload these operators for bool operands". In what situations would one want
to put a bool on the lhs of a compound assignment operator, but not for a
simple assignment operator?
Anthony
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: "J. Stephen Adamczyk" <jsa@edg.com>
Date: Wed, 14 Aug 2002 11:52:24 CST Raw View
In article <k7mt97h0.fsf@nortelnetworks.com> "Anthony Williams" <anthwil@nortelnetworks.com> writes:
>> This is resolved by core issue 221.
>
>However, I don't understand the comment about "if it did apply to compound
>assignment operators [i.e. they had to be members] it would be impossible to
>overload these operators for bool operands". In what situations would one want
>to put a bool on the lhs of a compound assignment operator, but not for a
>simple assignment operator?
I think that comment is only there to record an interesting observation
someone made. I don't think it's terribly relevant to the overall
decision on the core issue, and I don't think there's any claim that
being able to overload assignment operators (simple or compound) for
bool is either useful in general or more useful for compound assignment
operators than for the simple assignment operator.
Steve Adamczyk
Edison Design Group
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]