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 | 4009 |
2 | jiangly | 3831 |
3 | Radewoosh | 3646 |
4 | jqdai0815 | 3620 |
4 | Benq | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | gamegame | 3386 |
10 | ksun48 | 3373 |
# | User | Contrib. |
---|---|---|
1 | cry | 164 |
1 | maomao90 | 164 |
3 | Um_nik | 163 |
4 | atcoder_official | 160 |
5 | -is-this-fft- | 158 |
6 | awoo | 157 |
7 | adamant | 156 |
8 | TheScrasse | 154 |
8 | nor | 154 |
10 | Dominater069 | 153 |
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