typeid operator needs function call syntax?

  • Follow


Greetings!

The code in question is
   typeid(some_ref)

Now, in the spirit of sizeof, throw or return, I would expect the brackets
to be superflous, but they aren't (as GCC 3.3 says).

My questions are now
1. Is my assumption wrong that typeid is an operator? At least I seem to
remember that it is a reserved C++ keyword, no?
2. Why the divergence from other operators? Historical reasons?

thank you

Uli

-- 
Questions ?
see  C++-FAQ Lite: http://parashift.com/c++-faq-lite/  first !


      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
0
Reply Ulrich 11/21/2003 9:37:33 AM

In article <bpis3i$1p5h5a$1@ID-178288.news.uni-berlin.de>, Ulrich 
Eckhardt <doomster@knuut.de> writes
>The code in question is
>   typeid(some_ref)
>
>Now, in the spirit of sizeof, throw or return, I would expect the brackets
>to be superflous, but they aren't (as GCC 3.3 says).

Why that expectation? When I explicitly call operator new (rather than 
use the new expression) I have to use parentheses. catch requires 
parentheses, try requires braces, the C++ casts require parentheses etc. 
Strictly speaking sizeof isn't an operator (it isn't listed in 2.12)

>
>My questions are now
>1. Is my assumption wrong that typeid is an operator?
Depends on your understanding of what is meant by 'operator'

>At least I seem to
>remember that it is a reserved C++ keyword, no?

Being a reserved word is orthogonal to being an operator.  BTW are you 
claiming that return and throw are operators?

>2. Why the divergence from other operators? Historical reasons?
But I do not think your premise is correct. I suppose we could say that 
typeid is a reserved word and that typeid() is a two part operator like 
() and [] but what is gained by doing so?



-- 
Francis Glassborow      ACCU
If you are not using up-to-date virus protection you should not be reading
this. Viruses do not just hurt the infected but the whole community.


      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
0
Reply Francis 11/22/2003 3:00:38 AM


1 Replies
148 Views

(page loaded in 0.046 seconds)

Similiar Articles:













7/23/2012 7:06:12 AM


Reply: