C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

What is the name of 'operator +' ?

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards
View previous topic :: View next topic  
Author Message
Timothy Madden
Guest





PostPosted: Fri Oct 22, 2004 5:37 pm    Post subject: What is the name of 'operator +' ? Reply with quote



I'm reading the 1998 C++ standard. I find that:

"A name is an use of an identifier to denote an entity ... or a label"
and
"Two names are the same if
...
- they are the names of operator functions formed with the same operator
..."

Operator functions are entites (as they are functions) bat
which is the identifier to denote one of them ?

Timothy Madden


---
[ 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 ]

Back to top
Victor Bazarov
Guest





PostPosted: Sat Oct 23, 2004 2:56 am    Post subject: Re: What is the name of 'operator +' ? Reply with quote



Timothy Madden wrote:
Quote:
I'm reading the 1998 C++ standard. I find that:

"A name is an use of an identifier to denote an entity ... or a label"
and
"Two names are the same if
...
- they are the names of operator functions formed with the same operator
..."

Operator functions are entites (as they are functions) bat
which is the identifier to denote one of them ?

The _real_ name is internal (mangled) and is not standardised, but you
should be able to refer to operators by name 'operator@' where '@'
designates the operator symbol. Given that 'a' is of a class type,
a + b invokes either a.operator+(b) or operator+(a,b) , depending on the
way it is declared (a member or a non-member).

V

---
[ 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 ]


Back to top
Timothy Madden
Guest





PostPosted: Mon Oct 25, 2004 6:22 pm    Post subject: Re: What is the name of 'operator +' ? Reply with quote




"Victor Bazarov" <v.Abazarov (AT) comAcast (DOT) net> wrote

Quote:
Timothy Madden wrote:
[ ... ]
Operator functions are entites (as they are functions) bat
which is the identifier to denote one of them ?

The _real_ name is internal (mangled) and is not standardised, but you
should be able to refer to operators by name 'operator@' where '@'
designates the operator symbol. Given that 'a' is of a class type,
a + b invokes either a.operator+(b) or operator+(a,b) , depending on the
way it is declared (a member or a non-member).


My point here is 'operator +' is not a name, as it is not
'an use of an identifier' [basic].

Looks like the standard requires to consider '+', '*', etc as names.
What do you think ?

Timothy Madden


---
[ 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 ]


Back to top
Michiel Salters
Guest





PostPosted: Mon Oct 25, 2004 6:27 pm    Post subject: Re: What is the name of 'operator +' ? Reply with quote

[email]batman (AT) rmv (DOT) spam.home.ro[/email] ("Timothy Madden") wrote in message news:<2trtkkF23aucbU1 (AT) uni-berlin (DOT) de>...
Quote:
I'm reading the 1998 C++ standard. I find that:

"A name is an use of an identifier to denote an entity ... or a label"
and
"Two names are the same if
...
- they are the names of operator functions formed with the same operator
..."

Operator functions are entites (as they are functions) bat
which is the identifier to denote one of them ?

Timothy Madden

There is no identifier (2.10) associated with operators, even though
they're functions. A similar problem exists with ctors, which also
are functions.
13.5 explains what "the name" is for these cases:

A function declaration having one of the following "operator-function-ids"
as its name declares an operator function. An operator function is said to
implement the operator named in its operator-function-id.

operator-function-id:
"operator" operator
"operator" operator < template-argument-list opt >

operator: one of
"new" "delete" "new[]" "delete[]" + - [etcetera]

To answer the question in your title: the name is "operator +",
a two-token name and not an identifier. Technically, this might
just be a defect but I don't think it's very important.

Regards,
Michiel Salters

---
[ 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 ]


Back to top
Catalin Pitis
Guest





PostPosted: Tue Oct 26, 2004 8:51 am    Post subject: Re: What is the name of 'operator +' ? Reply with quote


""Timothy Madden"" <batman (AT) rmv (DOT) spam.home.ro> wrote

Quote:

"Victor Bazarov" <v.Abazarov (AT) comAcast (DOT) net> wrote in message
news:t7ced.6779$Ae.1349 (AT) newsread1 (DOT) dllstx09.us.to.verio.net...
Timothy Madden wrote:
[ ... ]
Operator functions are entites (as they are functions) bat
which is the identifier to denote one of them ?

The _real_ name is internal (mangled) and is not standardised, but you
should be able to refer to operators by name 'operator@' where '@'
designates the operator symbol. Given that 'a' is of a class type,
a + b invokes either a.operator+(b) or operator+(a,b) , depending on the
way it is declared (a member or a non-member).


My point here is 'operator +' is not a name, as it is not
'an use of an identifier' [basic].

Looks like the standard requires to consider '+', '*', etc as names.
What do you think ?

Timothy Madden



You can consider that

a + b

can be written as

a.operator+( b)

or

operator+( a, b)

depending on the declaration of the operator as class member or function.

Catalin


---
[ 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 ]


Back to top
Timothy Madden
Guest





PostPosted: Wed Oct 27, 2004 4:34 pm    Post subject: Re: What is the name of 'operator +' ? Reply with quote


"Michiel Salters" <Michiel.Salters (AT) logicacmg (DOT) com> wrote

Quote:
batman (AT) rmv (DOT) spam.home.ro ("Timothy Madden") wrote in message
news:<2trtkkF23aucbU1 (AT) uni-berlin (DOT) de>...
I'm reading the 1998 C++ standard. I find that:
[...]
Operator functions are entites (as they are functions) bat
which is the identifier to denote one of them ?

Timothy Madden

There is no identifier (2.10) associated with operators, even though
they're functions. A similar problem exists with ctors, which also
are functions.
13.5 explains what "the name" is for these cases:

A function declaration having one of the following "operator-function-ids"
as its name declares an operator function. An operator function is said to
implement the operator named in its operator-function-id.

operator-function-id:
"operator" operator
"operator" operator < template-argument-list opt

operator: one of
"new" "delete" "new[]" "delete[]" + - [etcetera]

To answer the question in your title: the name is "operator +",
a two-token name and not an identifier. Technically, this might
just be a defect but I don't think it's very important.

Any proposals to adjust the definition of a name in the standard ?

Or adjusts statements that operator functions would have names ?

Timothy Madden


---
[ 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 ]


Back to top
Sven Rosvall
Guest





PostPosted: Sat Oct 30, 2004 10:33 pm    Post subject: Re: What is the name of 'operator +' ? Reply with quote

[email]batman (AT) rmv (DOT) spam.home.ro[/email] ("Timothy Madden") writes:

Quote:
My point here is 'operator +' is not a name, as it is not
'an use of an identifier' [basic].

Looks like the standard requires to consider '+', '*', etc as names.
What do you think ?

Well, 'operator+' _is_ a name. You are right, it is not using an
identifier, but a name is not the same thing as an identifier.

Another example to illustrate:

namespace NS {
int a;
}

Here we declare an object with the name 'NS::a'. This uses _two_
identifiers plus the scope operator.

There are also complex examples of names that are built up using
templates.

Hope this helps
/ Sven
--

---
[ 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 ]


Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.