|
|
typeid operator needs function call syntax?
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: Misuses of RTTI - comp.lang.c++.moderatedIf a scripted statement asks ... this > direct use of typeid operator ... implementations typeid is equivalent to a virtual function call while dynamic_cast might need to do ... Avoiding problems with short-circuit primitive operator&& versus ...... does not conform to the function call ... other hand, user defined operator&& with user defined parameters is a function, and has function call ... common situation, when I need ... syntax error "missing ; before statement" - comp.lang.javascript ...thanks, function fillBu(){ var ... too large - comp.soft-sys.math ..... operator in SELECT statement ... missing ... has been deleted" "statement needs ... std::map< MyString, MyString > comparison operator? - comp.lang ...bool operator<( .. ) const Is all you need to declare. ... const char ** syntax question ... templates. - comp ... operator==(), being a const member function, cannot call ... Error: "syntax error: got (, expecting Newline" - comp.lang.c++ ...... hellofunc.h" > int main() > { > // call a function in ... cc -o hello ..', while the first two probably need ... Error: "syntax error: got (, expecting Newline" - comp ... Wrap a function - comp.lang.pythonCreate a function (say, "Run") that encapsulates as much of the syntax as possible: os.system(), subprocess.call ... No need to re ... system call - instead, it is a function ... need to kill worker process in parfor loop - comp.soft-sys.matlab ...The tilde operator can be used to indicate an ... b, and OPTIONS *would* be a supported syntax ... If you need to call a function handle with the parfor index ... Why no std::back_insert_iterator::value_type? - comp.lang.c++ ...Doesn't need T parameter ... The only valid use of an operator* is on the left side of the assignment statement." ... to a reference type using function-style syntax is ... Bad use of stringstream temporary? - comp.lang.c++... that closes the declaration statement. The ... and roll it as many times as they need ... reference argument of the free function operator<< for char*, so that the call no ... MERGE statement consuming all available CPU - comp.databases.ibm ...... Input Streams: ----- 19) From Operator #2 ... 3D INDATA.FIRE_LOGIN_TRIGGERS Hi Tonkuma, I need ... suspect the threads in the OS system call is what is ... Operator Overloading - Microsoft Corporation: Software ...Function call — ( ) Cast Operator. Unary * Multiplication ... Need more code examples ... sizeof and typeid operator overloading typeid Operator (C++) - Microsoft Corporation: Software ...The typeid operator allows the type of an object to be ... Need more code examples ... Terms of Use | Trademarks | Privacy Statement | Site ... 7/23/2012 7:06:12 AM
|
|
|
|
|
|
|
|
|