Hello programmers,,
I read someones code a couple days earlier and i saw a piece of code using __typeof operator as a shortcut of a for loop. What is this operator and can it be used ?? Thanks :D
# | User | Rating |
---|---|---|
1 | tourist | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 155 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
10 | nor | 152 |
Hello programmers,,
I read someones code a couple days earlier and i saw a piece of code using __typeof operator as a shortcut of a for loop. What is this operator and can it be used ?? Thanks :D
Name |
---|
Before the C++11 standard it was a function in GNU C++, that returns type of argument. For example:
It was removed in C++11 because of
auto
."replace" would be more appropriate word here, because typeof is not a nomral C function. it is more of a pre-compiler replacement (well, like, macros)
Actually it was replaced by
decltype
, notauto
.Yes i started using auto and it was more practical and easier than iterators Thank you :D
adamant seems to have the answer as to what it does. i would like to add that
typeof
(not__typeof
, btw) is not a C/C++ operator, but a compiler extension provided by GCC (which means it does not work on some other compilers).Im using VS 2013 and the syntax is __typeof But the problem is that it keeps telling me that "identifier is undefined" Do you have any explanation ??
i'm not very sure about VS 2013 interface; u can ask others who use it. i use Sublime Text 2 as my editor and Ubuntu Terminal to compile and run the code.
but i can tell u that in my template (from any of my recent submissions) i have the following line.
#define TR(i,x) for(typeof(x.begin()) i=x.begin();i!=x.end();i++)
here u can see that i use
typeof()
(i should change it toauto
from now), not__typeof
. this compiles and runs very well.I started using auto like the one you mentioned earlier. Any way auto worked just fine,and there is no need to change it into typeof. Thank you for your help :D
namedir oytyan? name bolsa gowy? wiii yatdan cykypdyr son gulerin