order of calling overloaded operators

E

ES Kim

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?
 
J

Jonathan Mcdougall

ES said:
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
 
L

Luke Meyers

Jonathan said:
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
 
J

Jonathan Mcdougall

Luke said:
Jonathan said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top