Topic: What is the name of 'operator +' ?
Author: sven-e@lysator.liu.se (Sven Rosvall)
Date: Sat, 30 Oct 2004 22:33:42 GMT Raw View
batman@rmv.spam.home.ro ("Timothy Madden") writes:
>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 ]
Author: batman@rmv.spam.home.ro ("Timothy Madden")
Date: Fri, 22 Oct 2004 17:37:42 GMT Raw View
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 ]
Author: v.Abazarov@comAcast.net (Victor Bazarov)
Date: Sat, 23 Oct 2004 02:56:04 GMT Raw View
Timothy Madden wrote:
> 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 ]
Author: batman@rmv.spam.home.ro ("Timothy Madden")
Date: Mon, 25 Oct 2004 18:22:52 GMT Raw View
"Victor Bazarov" <v.Abazarov@comAcast.net> wrote in message
news:t7ced.6779$Ae.1349@newsread1.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
---
[ 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: Michiel.Salters@logicacmg.com (Michiel Salters)
Date: Mon, 25 Oct 2004 18:27:26 GMT Raw View
batman@rmv.spam.home.ro ("Timothy Madden") wrote in message news:<2trtkkF23aucbU1@uni-berlin.de>...
> 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 ]
Author: catalin.pitis@iquestint.com.renameme ("Catalin Pitis")
Date: Tue, 26 Oct 2004 08:51:09 GMT Raw View
""Timothy Madden"" <batman@rmv.spam.home.ro> wrote in message
news:2u3r3mF2612dnU1@uni-berlin.de...
>
> "Victor Bazarov" <v.Abazarov@comAcast.net> wrote in message
> news:t7ced.6779$Ae.1349@newsread1.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 ]
Author: batman@rmv.spam.home.ro ("Timothy Madden")
Date: Wed, 27 Oct 2004 16:34:06 GMT Raw View
"Michiel Salters" <Michiel.Salters@logicacmg.com> wrote in message
news:fcaee77e.0410250140.55e1803e@posting.google.com...
> batman@rmv.spam.home.ro ("Timothy Madden") wrote in message
news:<2trtkkF23aucbU1@uni-berlin.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 ]