470,849 Members | 681 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,849 developers. It's quick & easy.

order of calling overloaded operators

iterator classes provide overloaded operators like this in general:

template <typename T>
class Iterator
{
Iterator operator++(int); // postfix ++
T& operator*();
};

Iterator<int> i;
*i++;

You know postfix ++ has higher precedence than unary *.
Does it gaurantee that postfix ++ is called before unary * operator?

--
ES Kim
May 23 '06 #1
3 1571
ES Kim wrote:
iterator classes provide overloaded operators like this in general:

template <typename T>
class Iterator
{
Iterator operator++(int); // postfix ++
T& operator*();
};

Iterator<int> i;
*i++;

You know postfix ++ has higher precedence than unary *.
It`s the dereferencing operator, not unary * (which does not exist).
Does it gaurantee that postfix ++ is called before unary * operator?


Of course. The point of operator precedence is to guarantee the order
in which these operators are called.

*p++ is always *(p++) and a+b*c is always a+(b*c).
Jonathan

May 23 '06 #2
Jonathan Mcdougall wrote:
ES Kim wrote:
You know postfix ++ has higher precedence than unary *.


It's the dereferencing operator, not unary * (which does not exist).


Oh, come now. It's a unary operator represented by the symbol '*', and
you and everybody else knew exactly what the OP meant. In fact,
5.3.1 [expr.unary.op] uses the exact term "the unary * operator" to
refer to this entity. Perhaps you just enjoy bullying, rather than
helping to inform? If you're going to be pedantic, have the decency to
be correct.

Luke

May 23 '06 #3
Luke Meyers wrote:
Jonathan Mcdougall wrote:
ES Kim wrote:
You know postfix ++ has higher precedence than unary *.
It's the dereferencing operator, not unary * (which does not exist).


Oh, come now. It's a unary operator represented by the symbol '*', and
you and everybody else knew exactly what the OP meant. In fact,
5.3.1 [expr.unary.op] uses the exact term "the unary * operator" to
refer to this entity.


It was my intention to remove that line, but I forgot before posting. I
apologize.
Perhaps you just enjoy bullying, rather than
helping to inform? If you're going to be pedantic, have the decency to
be correct.


True.
Jonathan

May 23 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

20 posts views Thread by Brad Eck | last post: by
4 posts views Thread by masood.iqbal | last post: by
1 post views Thread by Alex Zhitlenok | last post: by
19 posts views Thread by Babis Haldas | last post: by
3 posts views Thread by andreas ames | last post: by
6 posts views Thread by LSW | last post: by
54 posts views Thread by Rasjid | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.